Centos7.5服务器安装(并添加用户) anaconda3 并配置 PyTorch1.0
Posted 汤姆啾
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7.5服务器安装(并添加用户) anaconda3 并配置 PyTorch1.0相关的知识,希望对你有一定的参考价值。
===========================================================================================
[[email protected] ~]$ sudo vim /etc/sudoers
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for admin:
admin is not in the sudoers file. This incident will be reported.
切换至root用户下
[[email protected] ~]$ su root
Password:
[[email protected] admin]# ls -l /etc/sudoers
-r--r-----. 1 root root 4328 Oct 30 10:38 /etc/sudoers
[[email protected] admin]# chmod -v u+w /etc/sudoers
mode of ‘/etc/sudoers’ changed from 0440 (r--r-----) to 0640 (rw-r-----)
[[email protected] admin]# ls -l /etc/sudoers
-rw-r-----. 1 root root 4328 Oct 30 10:38 /etc/sudoers
[[email protected] admin]# vim /etc/sudoers
在 root ALL=(ALL) ALL 后面加上 username ALL = (ALL) ALL,其中username表示用户名
[[email protected] admin]# chmod -v u-w /etc/sudoers
mode of ‘/etc/sudoers’ changed from 0640 (rw-r-----) to 0440 (r--r-----)
[[email protected] admin]# ls -l /etc/sudoers
-r--r-----. 1 root root 4438 Mar 11 09:34 /etc/sudoers
退出root用户
[[email protected] admin]# exit
exit
[[email protected] ~]$
添加用户
先切换至root用户下
adduser jiangshan
passwd jiangshan
adduser jinyan
passwd jinyan
chmod -v u+w /etc/sudoers
vim /etc/sudoers
在这一行root ALL=(ALL) ALL下
jiangshan ALL=(ALL) ALL # add by jiangshan with hands
jinyan ALL=(ALL) ALL # add by jiangshan with hands
chmod -v u-w /etc/sudoers
退出root用户
exit
===================================================================================================
安装wget
sudo yum install wget
下载 Anaconda3-2018.12-Linux-x86_64.sh
[[email protected] ~]$ wget https://repo.anaconda.com/archive/Anaconda3-2018.12-Linux-x86_64.sh
安装bzip2
sudo yum install -y bzip2
安装Anaconda3
bash Anaconda3-2018.12-Linux-x86_64.sh
######################################################
注意~初始设定的存放位置:
Do you wish the installer to initialize Anaconda3
in your /home/jiangshan/.bashrc ? [yes|no]
A backup will be made to: /home/jiangshan/.bashrc-anaconda3.bak
######################################################
使环境变量生效
$ source /home/jiangshan/.bashrc
测试
$ conda -V
conda 4.5.12
正常,下一步
安装PyTorch
设置镜像
# 添加Anaconda的清华镜像
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/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes
##################################
###PyTorch Build Stable (1.0)###
###Your OS Linux ###
###Package Conda ###
###Language Python 3.7 ###
###CUDA None ###
##################################
$ conda install pytorch-cpu torchvision-cpu -c pytorch
若以上自动不好使,则手动下载,手动安装pytorch、torchvision
$ cd /home/jiangshan/anaconda3/pkgs
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64/pytorch-cpu-1.0.1-py3.7_cpu_2.tar.bz2
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64/torchvision-cpu-0.2.1-py37_1.tar.bz2
conda install pytorch-cpu-1.0.1-py3.7_cpu_2.tar.bz2
conda install torchvision-cpu-0.2.1-py37_1.tar.bz2
测试
(base) [[email protected] pkgs]$ conda -V
conda 4.5.12
(base) [[email protected] pkgs]$ python
Python 3.7.1 (default, Dec 14 2018, 19:28:38)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.__version__
‘1.0.1.post2‘
以上是关于Centos7.5服务器安装(并添加用户) anaconda3 并配置 PyTorch1.0的主要内容,如果未能解决你的问题,请参考以下文章
OpenStack教程-04.在CentOS7.5上安装OpenStack-Rocky-安装Glance镜像服务组件
OpenStack教程-03.在CentOS7.5上安装OpenStack-Rocky-安装Keyston认证服务组件