整个系统修改cuda版本
GPU驱动版本
nvidia-smi
the available CUDA in my machine
$ ls /usr/local/ | grep cuda
如果没有需要的cuda 版本 先安装cuda版本。 Download and Extract the binaries
wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
sudo sh cuda_11.8.0_520.61.05_linux.run
MD5 checksum
install
chmod +x cuda_11.8.0_520.61.05_linux.run
sudo ./cuda_11.8.0_520.61.05_linux.run --silent --toolkit
check cuda toolkit 查看系统cuda所有版本
$ ls /usr/local/ | grep cuda
查看当前环境使用的cuda版本
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Thu_Nov_18_09:45:30_PST_2021
Cuda compilation tools, release 11.5, V11.5.119
Build cuda_11.5.r11.5/compiler.30672275_0
激活需要的cuda版本
python3.8 -m venv venv/my_env
source venv/my_env/bin/activate
echo "export PATH=/usr/local/cuda-11.8/bin:$PATH" >> venv/my_env/bin/activate
echo "LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH" >> venv/my_env/bin/activate
或者修改~/.bashrc 修改 vim ~/.bashrc
# <version> 须切换的CUDA版本号
export PATH=/usr/local/cuda-<version>/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-<version>/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
修改后更新: source ~/.bashrc
验证修改后是否生效
$ source venv/nerfstudio/bin/activate
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:33:58_PDT_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0
写个脚本切换cuda版本
这种方法使用脚本切换cuda 脚本 简单,参考一下link
$ ls /usr/local | grep cuda
cuda
cuda-11.7
cuda-11.8
cuda-12.2
$ source switch-cuda.sh cuda-12.2
Switched to CUDA cuda-12.2
创建module, load不同cuda--一般server cuda 管理方法
https://gist.github.com/garg-aayush/156ec6ddda3d62e2c0ddad00b7e66956
sudo apt-get update
sudo apt-get install environment-modules
source /usr/share/modules/init/bash
Create modulefiles for CUDA distributions 参考链接创建两个文本 并保存
# Check the currently loaded module
module list
# Check the available modules
module avail
# Load a specific cuda version
module load cuda/12.1
# Unload the currently loaded CUDA module
module unload cuda
# Load CUDA 11.8
module load cuda/11.8
module avail
---------------------------------------------------------- /usr/share/modules/modulefiles -----------------------------------------------------------
cuda/11.8 cuda/12.1 dot module-git module-info modules null use.own