Last active
August 10, 2024 05:00
-
-
Save bathtimefish/56ff714c0939c318a6e787f860b4355f to your computer and use it in GitHub Desktop.
WSL Ubuntu22.04 LTS に CUDA 12.2 をセットアップするためのスクリプト https://astherier.com/blog/2021/07/windows11-cuda-on-wsl2-setup/ に掲載のものを更新
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright (c) 2021 astherier | |
# This software is released under the MIT License. | |
# http://opensource.org/licenses/mit-license.php | |
# | |
#install-cuda-on-wsl.sh | |
#WSL2のUbuntu側で行うCUDA on WSLのセットアップスクリプト | |
#最終更新:2021/07/17 | |
#https://astherier.com/blog/2021/07/windows11-cuda-on-wsl2-setup/ | |
# | |
# Update: 2023/7/16 | |
# Author: BathTimeFish https://github.com/bathtimefish | |
# Comment: Updated some processes to allow CUDA 12.x setup on WSL Ubuntu 22.04 LTS. | |
#CUDAリポジトリ名(DISTRO)とインストールするパッケージ名(APT_INSTALL)を指定してください。 | |
#リポジトリ名を変更した場合、パッケージ名は明示的にCUDAツールキットを指定してください。 | |
#(wsl-ubuntu以外のリポジトリから「cuda」をインストールすると、ディスプレイドライバーまでインストールしようとしてしまうため) | |
export DISTRO=wsl-ubuntu | |
export APT_INSTALL=cuda | |
#export DISTRO=ubuntu2004 | |
#export APT_INSTALL=cuda-toolkit-11-4 | |
#CUDAリポジトリの登録 | |
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/${DISTRO}/x86_64/7fa2af80.pub | |
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/${DISTRO}/x86_64/3bf863cc.pub | |
echo "deb http://developer.download.nvidia.com/compute/cuda/repos/${DISTRO}/x86_64 /" | sudo tee /etc/apt/sources.list.d/cuda.list | |
wget https://developer.download.nvidia.com/compute/cuda/repos/${DISTRO}/x86_64/cuda-${DISTRO}.pin | |
sudo mv cuda-${DISTRO}.pin /etc/apt/preferences.d/cuda-repository-pin-600 | |
#CUDAツールキットのインストール | |
sudo apt update && sudo apt -y upgrade | |
sudo apt install -y ${APT_INSTALL} | |
#環境変数の設定 | |
cat << 'EOS' >> ~/.profile | |
#Added by install-cuda-on-wsl.sh | |
#Ref: https://astherier.com/blog/2021/07/windows11-cuda-on-wsl2-setup/ | |
export PATH=/usr/local/cuda-12/bin${PATH:+:${PATH}} | |
#Added: end | |
EOS | |
#サードパーティーライブラリのインストール(任意) | |
sudo apt install -y g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev | |
echo " | |
CUDA on WSLのセットアップが終了しました。 | |
動作確認のためサンプルプログラムをコンパイルして実行してみてください | |
git clone https://github.com/NVIDIA/cuda-samples | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment