Windows11のWSL2でUbuntu24.04をインストールした話

ubuntu コンピュータ
ubuntu

Windows11のWSL2でUbuntu22.04LTSをインストールしていたのですが、そろそろUbuntu24.04LTSに切り替えたいと思います。

インストール可能なディストリビュージョンの確認

wsl -l -o

インストールできる有効なディストリビューションの一覧を次に示します。
'wsl.exe --install <Distro>' を使用してインストールします。

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
Ubuntu-24.04                    Ubuntu 24.04 LTS
OracleLinux_7_9                 Oracle Linux 7.9
OracleLinux_8_7                 Oracle Linux 8.7
OracleLinux_9_1                 Oracle Linux 9.1
openSUSE-Leap-15.6              openSUSE Leap 15.6
SUSE-Linux-Enterprise-15-SP5    SUSE Linux Enterprise 15 SP5
SUSE-Linux-Enterprise-15-SP6    SUSE Linux Enterprise 15 SP6
openSUSE-Tumbleweed             openSUSE Tumbleweed

ディストリビュージョンのインストール

wsl --install -d Ubuntu-24.04

インストール中: Ubuntu 24.04 LTS
Ubuntu 24.04 LTS がインストールされました。
Ubuntu 24.04 LTS を起動しています...
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:ユーザー名
New password:パスワード
Retype new password:パスワード
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 24.04.1 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Thu Jan 23 20:41:13 JST 2025

  System load:  0.21                Processes:             50
  Usage of /:   0.1% of 1006.85GB   Users logged in:       0
  Memory usage: 1%                  IPv4 address for eth0: 172.30.169.50
  Swap usage:   0%


This message is shown once a day. To disable it please create the
/home/ユーザー名/.hushlogin file.

ディストリビュージョンを指定して起動

wsl --distribution Ubuntu-24.04 --user <User Name>

デフォルトディストリビュージョンの変更

wsl -s Ubuntu-24.04

ディストリビュージョンのイメージファイルの保存場所を移動

CUDA Toolkitのインストール

WSLでCUDAをインストールする場合ビデオカードのドライバーのインストールは不要な模様。
ホストであるWindows11でRTX4070用ビデオカードドライバーはインストール済み。

sudo apt-key del 7fa2af80
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.6.3/local_installers/cuda-repo-wsl-ubuntu-12-6-local_12.6.3-1_amd64.deb
sudo dpkg -i cuda-repo-wsl-ubuntu-12-6-local_12.6.3-1_amd64.deb
sudo cp /var/cuda-repo-wsl-ubuntu-12-6-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-6
echo 'export PATH=/usr/local/cuda-12.6/bin${PATH:+:${PATH}}' >> ~/.setcuda
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.6/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.setcuda
echo '. ~/.setcuda' >> ~/.bashrc

追記:
この後Stable Diffusion Web UI(AUTOMATIC1111版)をインストールしてみましたが、対応のPythonが3.10でUbuntu24.04のPythonのバージョンが3.13?でインストールが失敗します。Pythonのバージョンを合わせる方法もありそうですが、シンプルな方法としてはUbuntuを22.04に戻しその中でStabel Diffusionを動かした方が良さそうです。どうやら私にUbuntu24.04ははやすぎたようです。

コメント