= 機械学習環境を個人用PCにセットアップする = [[PageOutline]] 加速器機械学習フォーラムでの話題がきっかけで書きました。 初心者向けの環境構築の一例として活用いただけますと幸いです。 このセットアップ手順はWindowsPCで簡単に環境を構築する例となっていますが、WSL2を除けばbuntu環境や多くのLinux環境でそのまま使えるはずです。 概略 * WSL2 * python3インストール * venv 設定 * !TensorFlow インストール * !PyTorch インストール ここから先はまだ書いていない * GPU環境 (CUDA)でのセットアップ例 * GPyOptの使用例 * BOTorch, Axの使用例 * EPICS連携 == WSL2のインストール == 最初に__管理者権限で__コマンドプロンプトを開く。wslコマンドで、インストール可能なディストリビューションを検索・確認する。 (wslコマンドが無い場合は、適当にGoogleで検索してください) {{{ C:\>wsl --list --online インストールできる有効なディストリビューションの一覧を次に示します。 'wsl --install -d ' を使用してインストールします。 NAME FRIENDLY NAME Ubuntu Ubuntu Debian Debian GNU/Linux kali-linux Kali Linux Rolling Ubuntu-18.04 Ubuntu 18.04 LTS Ubuntu-20.04 Ubuntu 20.04 LTS Ubuntu-22.04 Ubuntu 22.04 LTS OracleLinux_7_9 Oracle Linux 7.9 OracleLinux_8_7 Oracle Linux 8.7 OracleLinux_9_1 Oracle Linux 9.1 SUSE-Linux-Enterprise-Server-15-SP4 SUSE Linux Enterprise Server 15 SP4 openSUSE-Leap-15.4 openSUSE Leap 15.4 openSUSE-Tumbleweed openSUSE Tumbleweed }}} [[Image(wsl_install1.png, 40%)]] ここではUbuntu22.04をインストールすることにする。 {{{ C:\>wsl --install --d Ubuntu-22.04 インストール中: Ubuntu 22.04 LTS Ubuntu 22.04 LTS はインストールされました。 Ubuntu 22.04 LTS を起動しています... }}} 自動的にUbuntuのターミナルが起動して、ユーザー名を入れるプロンプトが出るので、ユーザー名とパスワードを設定する。 (最初は少し時間がかかるかもしれない) {{{ Installing, this may take a few minutes... Please create a default UNIX user account. The username does not need to match your Windows username. For more information visit: https://aka.ms/wslusers Enter new UNIX username: obina New password: Retype new password: passwd: password updated successfully Installation successful! To run a command as administrator (user "root"), use "sudo ". See "man sudo_root" for details. Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.10.60.1-microsoft-standard-WSL2 x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage This message is shown once a day. To disable it please create the /home/obina/.hushlogin file. obina@notepc:~$ }}} [[Image(wsl_install2.png, 40%)]] いちおう確認 {{{ obina@notepc:~$ cat /etc/os-release PRETTY_NAME="Ubuntu 22.04.2 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.2 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy obina@notepc:~$ uname -a Linux notepc 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux }}} パッケージのアップデート。先ほど入力したパスワードを入れる {{{ obina@notepc:~$ sudo apt update Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease Get:2 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB] ..... Fetched 26.5 MB in 6s (4327 kB/s) Reading package lists... Done Building dependency tree... Done Reading state information... Done 19 packages can be upgraded. Run 'apt list --upgradable' to see them. }}} {{{ obina@notepc:~$ sudo apt upgrade Reading package lists... Done Building dependency tree... Done Reading state information... Done Calculating upgrade... Done The following packages will be upgraded: apt apt-utils distro-info-data git git-man libapt-pkg6.0 libglib2.0-0 libglib2.0-bin libglib2.0-data libssl3 libxml2 openssl tzdata ubuntu-advantage-tools vim vim-common vim-runtime vim-tiny xxd 19 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 10 standard LTS security updates Need to get 21.9 MB of archives. After this operation, 348 kB of additional disk space will be used. Do you want to continue? [Y/n] Y .... obina@notepc:~$ }}} [[Image(wsl_install3.png, 40%)]] とりあえずここまでで十分。 == python3インストール == == venv 設定 == == !TensorFlow インストール == == !PyTorch インストール ==