环境配置笔记22-ubantu安装深度学习环境全记录

2024-03-26  本文已影响0人  江湾青年

最近被ubantu18.04的编译环境整的够呛,一会是cmake有问题,一会是C++有问题,怒放弃18.04,重新整个20.04折腾!

创建新实例

选择镜像,设置密码,预留出几个端口,今后可能有用,最后点击确认。

创建新实例

确认之后要等一段时间,相当于装一个新系统,比较慢


root安装必要的包

https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b11zorqQM

# 先安装vim
apt install vim
# 换源
rm -rf /etc/apt/sources.list
vim /etc/apt/sources.list
# 替换为上面网址里deb开头的一大堆
apt update
apt install lsb
lsb_release -a
apt install ssh
# 启动ssh服务
service ssh start
# 允许root登陆
vi /etc/ssh/sshd_config
# 添加以下内容:
PermitRootLogin yes
# 重启ssh服务
service ssh restart

小插曲:以上操作并不生效,因为我使用的镜像不是平台提供的,有些配置对不上。查看/etc/ssh/ssh_config文件顶部的Port的值,还是22,要改为实例端口的6006。最后重启ssh服务,即可远程连接登陆。

https://www.jianshu.com/p/67bf555b427e

apt install tree git sudo wget vim inetutils-ping ssh tmux less
apt install libcurl4-openssl-dev libssl-dev libxml2-dev libfontconfig1-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev  libgeos-dev cmake libudunits2-dev libgdal-dev libgsl-dev libgmp3-dev libgfortran5 pigz lbzip2 libcairo2-dev libxt-dev libharfbuzz-dev libfribidi-dev libboost-all-dev libbz2-dev default-jre

https://mirrors.tuna.tsinghua.edu.cn/CRAN/

sudo apt update -qq
sudo apt install --no-install-recommends software-properties-common dirmngr
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
sudo apt install --no-install-recommends r-base

创建用户并设为管理员

https://www.jianshu.com/p/975f0056d669

useradd -d /home/txm -m  txm
passwd txm
# 修改bash
vim /etc/passwd
vim /etc/sudoers

https://www.jianshu.com/p/825fd4fca89a

sudo usermod -u 1003 txm          # 修改txm的用户id(uid)为1003
sudo groupmod -g 1003 txm          # 修改txm组的id为1003
ln -s /remote-home/share/mdshare /mdshare

安装个人软件

su txm
ln -s /mdshare/node8/txmdata ~/txmdata

https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html

# 查看系统架构
dpkg --print-architecture
## amd64
# 官方推荐 Fresh install,即全新安装(without conda)
# https://github.com/conda-forge/miniforge?tab=readme-ov-file
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
bash Miniforge3-Linux-x86_64.sh
# 一路yes,最后
source ~/.bashrc

参考:https://www.jianshu.com/p/a15f9e0c1f38

mamba create -n DL python=3.8
mamba activate DL

安装pytorch之前,首先查看GPU的CUDA版本

nvidia-smi
CUDA版本为11.2

然后去pythrch官网 https://pytorch.org/get-started/locally/查看对应系统和CUDA版本的代码

image.png

由于实验室GPU的CUDA版本为11.2,不是最新的,在https://pytorch.org/get-started/previous-versions/寻找对应自己CUDA版本的pytorch安装代码。

我安装的是cuda版本为11.1的pytorch(cuda11.2的pytorch没有)

pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

最难装的pytorch装好,其他的包直接mamba install就完事啦!


参考

https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b11zorqQM
https://www.jianshu.com/p/67bf555b427e
https://mirrors.tuna.tsinghua.edu.cn/CRAN/
https://www.jianshu.com/p/975f0056d669
https://www.jianshu.com/p/825fd4fca89a
https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html
https://www.jianshu.com/p/a15f9e0c1f38
https://pytorch.org/get-started/previous-versions/

上一篇 下一篇

猜你喜欢

热点阅读