wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda_11.1.0_455.23.05_linux.runsudo sh cuda_11.1.0_455.23.05_linux.run
sudo sh ./cuda_11.1.0_455.23.05_linux.run
如果使用wegt下载报错,可以直接在浏览器输入后面的网址下载
历史版本下载地址 https://developer.nvidia.com/cuda-toolkit-archive
wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda_11.1.0_455.23.05_linux.run
sudo sh ./cuda_10.2.89_440.33.01_linux.run
如果本机已经有了Driver则第一项不要选择,上下键移动到Driver然后Enter即可不选择
添加环境变量
sudo gedit ~/.bashrc
添加
export PATH=/usr/local/cuda-11.1bin${PATH:+:$PATH}}
export CUDA_HOME=/usr/local/cuda-11.1
export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64:$LD_LIBRARY_PATH
source ~/.bashrc
查看安装是否成功
nvcc -V
cuda10.0及以下的卸载:
cd /usr/local/cuda-xx.x/bin/
sudo ./uninstall_cuda_xx.x.pl
sudo rm -rf /usr/local/cuda-xx.x
#xxxx为版本号
cuda10.1及以上的卸载:
cd /usr/local/cuda-xx.x/bin/
sudo ./cuda-uninstaller
sudo rm -rf /usr/local/cuda-xx.x
网址 https://developer.nvidia.com/rdp/cudnn-download
下载cudnn-local-repo-ubuntu1804-8.3.1.22_1.0-1_amd64.deb文件
直接点击安装或者
sudo dpakg -i xxx.deb
bash ./Anaconda3-2021.11-Linux-x86_64.sh
最后一项选择yes
查看版本
conda -V
为conda添加源(重新打开一个终端,用户名前面有(base)表示在conda环境中)
sudo gedit ~/.condarc
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/simpleitk/
show_channel_urls: true
#
conda create -n 环境名字 python=3.7 -y
conda activate 环境名字
#指定python版本新建环境
conda create --name your_env_name python=3.5
#创建包含某些包的环境
conda create --name your_env_name numpy scipy
#列举当前所有环境
conda info --envs
conda env list
#进入某个环境
source activate your_env_name
#退出环境
conda deactivate
#取消默认加载环境
conda config --set auto_activate_base false
#删除Anaconda3文件夹
sudo rm -rf ~/anaconda3
#删除Anaconda·配置的环境变量
sudo rm -rf ~/anaconda3
#更新环境变量,使更改生效
source ~/.bashrc
创建虚拟环境
conda create -n pytorch python=3.6
#创建的虚拟环境在/home/user_name/anaconda3/envs里面
conda activate pytorch
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch-lts -c nvidia
https://developer.nvidia.com 官网查看安装命令
安装tensorflow
conda create -n tf #创建tensorflow虚拟环境
conda create -n tf #进入tensorflow虚拟环境
conda deactivate #退出tensorflow虚拟环境
conda install tensorflow-gpu #安装tensorflow
sudo apt install python3-dev python3-pip
pip install -U --user pip numpy wheel
pip install -U --user keras_preprocessing --no-deps
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl https://storage.googleapis.com/bazel-apt/doc/apt-key.pub.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install bazel-3.7.2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
如果要切换到Python2,执行:
sudo update-alternatives --config python