准备
在完成系统安装后,https://blog.csdn.net/woshigaowei5146/article/details/125411831?spm=1001.2014.3001.5501
下载anaconda:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
安装Anaconda3
下载好后,到下载路径。
bash Anaconda3-5.3.1-Linux-x86_64.sh
配置环境变量
sudo gedit ~/.bashrc
在最后一行中加入自己安装的anaconda下bin的路径:
#set Anaconda3 environment
export PATH="/home/zlt/anaconda3/bin:$PATH"
保存关闭文件后,使其生效:
source ~/.bashrc
输入python,验证。
安装Tensorflow
用conda新建一个python版本为3.6的虚拟环境。
conda create -n tensorflow python=3.6
激活虚拟环境
source activate tensorflow
安装tensorflow,注意没有GPU的不要装GPU版本,否则系统报错。
(tensorflow)$ pip install --ignore-installed --upgrade tfBinaryURL
其中 tfBinaryURL 是 TensorFlow Python 包的 URL。例如,如下命令安装了仅支持 CPU 的 Python 3.4 版本下的 TensorFlow:
(tensorflow)$ pip install --ignore-installed --upgrade \
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp34-cp34m-linux_x86_64.whl
我用的命令:
pip install --ignore-installed --upgrade \https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp36-cp36m-linux_x86_64.whl
如果安装速度慢,可换源或下载好后安装。
tensorflow对应的python版本清单:
https://tensorflow.google.cn/install/source_windows#cpu
其他版本:
Python 2.7 仅支持 CPU:
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp27-none-linux_x86_64.whl
支持 GPU:https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.8.0-cp27-none-linux_x86_64.whl
注意 GPU 支持需要符合 NVIDIA 对运行 GPU 支持版本的 TensorFlow 的要求 的软硬件要求。Python 3.4 仅支持 CPU:
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp34-cp34m-linux_x86_64.whl
支持 GPU:https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.8.0-cp34-cp34m-linux_x86_64.whl
注意 GPU 支持需要符合 NVIDIA 对运行 GPU 支持版本的 TensorFlow 的要求 的软硬件要求。Python 3.5 支持 CPU:
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp35-cp35m-linux_x86_64.whl
GPU 支持:https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.8.0-cp35-cp35m-linux_x86_64.whl
注意 GPU 支持需要符合 NVIDIA 对运行 GPU 支持版本的 TensorFlow 的要求 的软硬件要求。Python 3.6 仅支持 CPU:
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp36-cp36m-linux_x86_64.whl
GPU 支持:https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.8.0-cp36-cp36m-linux_x86_64.whl
我之前估计是用了pip install --upgrade tensorflow命令,导致开机出现了错误:amdgpu unable to locate a bios ro。
验证安装
先看看自己的tensorflow版本,可以看到我安装版本的是1.3.0
pip list
输入python来运行:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
安装Pytorch
进入 Pytorch 官网。下滑找到配置列表,按照图示参数进行选择。
https://pytorch.org/
CPU版本:
conda install pytorch torchvision torchaudio cpuonly -c pytorch
输入进行验证:
import torch
torch.__version__
安装PyCharm
官网下载open-source压缩包
https://www.jetbrains.com/pycharm/download/#section=linux
解压缩进入bin目录,运行pycharm.sh
bash pycharm.sh
创建快捷方式
cd /usr/share/applications
sudo gedit pycharm.desktop
添加以下内容:
[Desktop Entry]
Version=1.0
Type=Application
Name=Pycharm
Icon=/home/gw/下载/pycharm/pycharm-community-2022.1.3/bin/pycharm.png
Exec=sh /home/gw/下载/pycharm/pycharm-community-2022.1.3/bin/pycharm.sh
MimeType=application/x-py;
Name[en_US]=pycharm
Icon和Exec的绝对路径从安装位置复制。
pycharm换源
https://blog.csdn.net/qq_36545208/article/details/125312331
https://pypi.tuna.tsinghua.edu.cn/simple/
参考
https://blog.csdn.net/elsa001/article/details/119150775
https://tensorflow.juejin.im/install/install_linux.html#toc-16
https://blog.51cto.com/u_14251143/5346899
https://blog.csdn.net/qq_34907927/article/details/109719858