ubuntu22.04-cuda12.4环境配置
卸载原驱动
Removing CUDA Toolkit and Driver
删除 CUDA 工具包:
sudo apt-get --purge remove "*cuda*" "*cublas*" "*cufft*" "*cufile*" "*curand*" \
"*cusolver*" "*cusparse*" "*gds-tools*" "*npp*" "*nvjpeg*" "nsight*" "*nvvm*"
删除 NVIDIA 驱动程序:
sudo apt-get --purge remove "*nvidia*" "libxnvctrl*"
清理卸载:
sudo apt-get autoremove
安装显卡驱动
安装
CUDA Toolkit 12.4 Downloads CUDA Toolkit 12.6 Downloads
wget https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_550.54.14_linux.run
sudo sh cuda_12.4.0_550.54.14_linux.run
若安装失败可查看对应日志,针对性解决
vim /var/log/cuda-installer.log
vim /var/log/nvidia-installer.log
g++版本不对应问题
卸载原g++,gcc
sudo apt-get purge gcc g++
安装对应版本gcc
sudo apt install gcc-12
将对应版本的地址连接到
sudo ln -s /user/bin/gcc-12 /usr/bin/gcc
查看版本是否对应
gcc --version
将gcc目录链接到cc
sudo ln -s /usr/bin/gcc /usr/bin/cc
安装Miniconda
Miniconda软件安装教程(Linux) 清华大学开源软件镜像站
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py38_4.8.3-Linux-x86_64.sh --no-check-certificate
bash Miniconda3-py38_4.8.3-Linux-x86_64.sh
升级conda
搜索可用的conda版本
conda search conda
安装一个较新的版本
conda install conda=24.7.1
安装pytorch
conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia
查看是否安装成功
python -c "import torch;print(torch.cuda.device_count())"
安装需要的包
pip install pytorch-lightning -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install timm torchinfo tqdm openpyxl einops
pip install numpy pandas matplotlib scikit-learn fastparquet
pip install tushare fastapi loguru websockets
pip install tensorboard==2.12.0 tensorboardx