Ubuntu 18.04.4 LTS (Bionic Beaver)
推荐工具:rufus
注意:一定将bios设置中安全启动选项关闭!
大小(MB) | 类型 | 挂载点 |
---|---|---|
30720MB | 主分区 | / |
8194MB | 交换空间 | |
1024MB | 逻辑分区 | /boot |
其余所有空间 | 逻辑分区 | /home |
(1)在所有软件中,找到"软件与更新"并打开
(2)Ubuntu软件->下载自->其他站点->http://mirrors.aliyun.com/ubuntu
# 终端输入:
sudo apt-get update
sudo apt-get upgrade
(1)安装ssh-server
sudo apt-get install openssh-server
(2)查看ssh-server状态
sudo ps -e | grep ssh
若有sshd条目则成功启动
(3)启动命令:service sshd start
参考Tensorflow官方GPU配置指南进行搭建。
# 终端输入:
sudo apt-get purge nvidia*
sudo apt --purge remove "cublas*" "cuda*"
# 终端输入:(本部分内容实时动态更新,以上方官网链接中内容为准):
# Add NVIDIA package repositories
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.243-1_amd64.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo dpkg -i cuda-repo-ubuntu1804_10.1.243-1_amd64.deb
sudo apt-get update
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
sudo apt install ./nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
sudo apt-get update
# Install NVIDIA driver
sudo apt-get install --no-install-recommends nvidia-driver-430
# 重启后终端输入"nvidia-smi"测试驱动是否成功安装
sudo apt-get update
sudo apt-get upgrade
# Install development and runtime libraries (~4GB)
sudo apt-get install --no-install-recommends \
cuda-10-1 \
libcudnn7=7.6.4.38-1+cuda10.1 \
libcudnn7-dev=7.6.4.38-1+cuda10.1
# Install TensorRT. Requires that libcudnn7 is installed above.
sudo apt-get install -y --no-install-recommends libnvinfer6=6.0.1-1+cuda10.1 \
libnvinfer-dev=6.0.1-1+cuda10.1 \
libnvinfer-plugin6=6.0.1-1+cuda10.1
(1)安装
# 终端输入:
sudo apt-get install libcupti-dev
(2)配置环境变量
终端输入:sudo gedit ~/.bashrc
增加行:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64
,保存并退出
终端输入:source ~/.bashrc
注意:实时监测显卡状态命令watch -n 0.5 nvidia-smi
Annaconda清华镜像站获取最新版本,下载至本地。
bash Anaconda3-5.2.0-Linux-x86_64.sh
(文件名)开始安装。sudo gedit ~/.bashrc
export PATH="/home/XXX/anaconda3/bin:$PATH"
并保存。(注意XXX处为自己的用户名)
source ~/.bashrc
conda config --show channels
conda config --remove channels url
# 例:conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/
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 update conda
sudo ufw status # 查看已经开启的端口
sudo ufw allow 9999 # 打开9999端口
sudo ufw enable # 防火墙开启
sudo ufw reload # 防火墙重启
jupyter notebook --generate-config
In [1]: from IPython.lib import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: '复制此密码'
sudo gedit ~/.jupyter/jupyter_notebook_config.py
修改以下内容:
c.NotebookApp.ip = '*' #所有绑定服务器的IP都能访问,若想只在特定ip访问,输入ip地址即可
c.NotebookApp.password = 'sha:...粘贴密码'
c.NotebookApp.allow_remote_access = True
c.NotebookApp.port = 9999 # 选择刚才开放的端口
c.NotebookApp.open_browser = False #我们并不想在服务器上直接打开Jupyter Notebook,所以设置成False
c.NotebookApp.notebook_dir = '可自定义路径' #设置Jupyter的根目录
c.NotebookApp.allow_root = True # 为了安全,Jupyter默认不允许以root权限启动jupyter
conda create -n tensorflow_env --clone base
source activate tensorflow_env
终端输入:
pip install --upgrade pip
pip install tensorflow==2.1.0
注意:若出现
ERROR: Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
则输入:pip install wrapt --ignore-installed
并重新安装
输入ipython,输入:
import tensorflow as tf
print(tf.config.list_physical_devices())
若输出GPU、CPU信息,如:
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'),
PhysicalDevice(name='/physical_device:XLA_CPU:0', device_type='XLA_CPU'),
PhysicalDevice(name='/physical_device:XLA_GPU:0', device_type='XLA_GPU'),
PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
则可以正常调用GPU、CPU。
conda create -n pytorch_env --clone base
source activate pytorch_env
终端输入:
pip install --upgrade pip
# 注意:安装命令关注官网实时更新https://pytorch.org/get-started/locally/
pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
输入ipython,并输入:
import torch
print(torch.cuda.is_available())
若输出True则成功安装