ubuntu18.04.5安裝anaconda,顯卡驅(qū)動,cuda10.1,pytorch1.6和tensorflow

anaconda3安裝

參考鏈接:

https://blog.csdn.net/qq_15192373/article/details/81091098

對應(yīng)命令:

bash Anaconda3-5.2.0-Linux-x86_64.sh

cuda10.1安裝

安裝cuda前的準(zhǔn)備參考鏈接:

https://www.e-learn.cn/topic/3766913

對應(yīng)到命令:

uname -m && cat /etc/*release
uname -r
sudo apt-get install linux-headers-$(uname -r)
sudo apt-get remove --purge nvidia*
sudo apt-get update
sudo apt-get install dkms build-essential linux-headers-generic

安裝驅(qū)動和cuda10.1+cudnn參考鏈接:

https://blog.csdn.net/sun_5flower/article/details/109777072

對應(yīng)命令:

ubuntu-drivers devices
sudo ubuntu-drivers autoinstall
nvidia-smi
gcc --version
g++ --version
sudo sh cuda_10.1.168_418.67_linux.run
cd ~
sudo gedit .bashrc

然后在文件末尾添加:

# add cuda path    # 在文件末尾添加路徑
export PATH="/usr/local/cuda-10.1/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH"

保存然后在終端輸入:

sudo gedit /etc/profile

在文件末尾添加:

# add cuda path  # 文件末尾增加以下兩行代碼
export PATH="/usr/local/cuda-10.1/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH"

保存在終端輸入使其生效:

source .bashrc

驗證是否安裝成功:

nvcc -V

cudnn對應(yīng)命令:

sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.1_amd64.deb
sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.1_amd64.deb
sudo dpkg -i libcudnn7-doc_7.6.5.32-1+cuda10.1_amd64.deb
cp -r /usr/src/cudnn_samples_v7 /$HOME
cd $HOME/cudnn_samples_v7/mnistCUDNN/
sudo make clean
sudo make
sudo ./mnistCUDNN

安裝pytorch

添加鏡像:

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 --set show_channel_urls yes

創(chuàng)建虛擬環(huán)境:

conda create --name python38 python=3.8 anaconda

激活虛擬環(huán)境:

source activate python38

添加鏡像:

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 --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

選擇安轉(zhuǎn)的版本:

conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1

寫一個簡單的代碼驗證是否安裝成功:

import torch
print(torch.__version__)
print('gpu:',torch.cuda.is_available())

pip安裝cv2庫

pip install opencv-python=4.1.2

安裝tensorboard:

conda install tensorboard==2.2

安裝tensorflow1.4+keras

對應(yīng)命令:

conda create --name tf14 python=3.6 anaconda
pip install --ignore-installed --upgrade tensorflow-gpu==1.14.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

由于鏡像會出問題:

conda config --remove-key channels
conda config --append channels conda-forge --append channels bioconda --append channels defaults

添加鏡像:

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 --set show_channel_urls yes

安裝keras:

pip install keras==2.1.3

安裝pycharm

參考鏈接:

https://blog.csdn.net/feimeng116/article/details/105837483
對應(yīng)命令:

tar -zxvf pycharm-community-2020.1.5.tar.gz
sudo mkdir /opt/pycharm
sudo mv pycharm-2020.1/ /opt/pycharm/
cd /opt/pycharm/
ls
sh /opt/pycharm/pycharm-2020.1/bin/pycharm.sh
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容