ubuntu+anaconda+cuda+cudnn+pycharm+tensorflow
安装wget vim
sudo apt-get install wget
sudo apt-get install vim
安装anaconda
#在https://www.anaconda.com/直接下载,然后安装
sh Anaconda3-2021.11-Linux-x86_64.sh
yes
yes
#将Anaconda添加到用户环境变量中
vim ~/.bashrc
#添加下面内容
export PATH="/home/ssj/anaconda3/bin:$PATH"
#然后
source ~/.bashrc
#查看版本
conda -V
#添加镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
安装cuda11.4
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda-repo-ubuntu2004-11-4-local_11.4.0-470.42.01-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2004-11-4-local_11.4.0-470.42.01-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu2004-11-4-local/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda
卸载cuda
cd /usr/local/cuda-11.4/bin/
sudo ./cuda-uninstaller
sudo rm -rf /usr/local/cuda-11.4
设置cuda环境
#使用指令打开.bashrc:
sudo vim ~/.bashrc
#接着在最后面添加三行指令:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.4/lib64
export PATH=$PATH:/usr/local/cuda-11.4/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda-11.4
#然后
source ~/.bashrc
#查看版本
nvcc-V
安装cudnn
wget https://developer.download.nvidia.cn/compute/cudnn/secure/8.4.0/local_installers/11.6/cudnn-local-repo-ubuntu2004-8.4.0.27_1.0-1_amd64.deb
sudo dpkg -i cudnn-local-repo-ubuntu2004-8.4.0.27_1.0-1_amd64.deb
下载pycharm
#在https://www.jetbrains.com/pycharm/download/download-thanks.html?platform=linux&code=PCC下载解压,然后
sh pycharm.sh
创建虚拟环境
conda create -n tensorflow python=3.8
conda activate tensorflow
pip install --upgrade pip
pip install --upgrade tensorflow
python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

浙公网安备 33010602011771号