Ubuntu server配置
1、安装完成后,对Ubuntu进行更新并配置ssh远程连接服务
首先对Ubuntu系统进行更新
sudo apt update
sudo apt upgrade
再对Ubuntu系统进行ssh远程链接配置
sudo apt install ssh
sudo vim /etc/ssh/sshd_config
将#PermitRootLogin prohibit-password修改为
再重启ssh服务以生效
sudo systemctl start sshd
ssh服务停止指令:
sudo systemctl stop sshd
2、Ubuntu更换为国内源
sudo nano /etc/apt/sources.list
将原有源注释,再添加一下源(阿里源)
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
再更新系统:
sudo apt-get update
sudo apt-get upgrade
3、若有除系统盘外其他硬盘,可将硬盘进行挂载后使用
编辑etc/fstab文件
sudo vim etc/fstab
在打开的文件中加入
/dev/sdb /home/data ext4 defaults 0 0 (sdb为待挂载盘的编号,可使用lsblk指令查看)
4、Ubuntu安装xrdp远程桌面
首先安装GNOME桌面
sudo apt-get install tasksel -y
sudo tasksel
将打开一个基于curses的GUI。使用键盘箭头键,向下滚动以选择Ubuntu desktop(空格键选择),并按Enter继续安装,完成后重启Ubuntu系统
检查Xrdp是否已安装
sudo systemctl status xrdp
若显示Unit xrdp.service could not be found.表示未安装
sudo apt-get install xrdp -y
完成后再次检查
sudo systemctl status xrdp
5、将Ubuntu系统语言更改为中文
安装中文包
sudo apt-get install language-pack-zh-hans
更改配置文件
sudo vim /etc/default/locale
将配置文件内容更改为
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:zh:en_US:en
重启系统,提示更改文件夹名称,选择keep old name
6、安装显卡驱动、CUDA、CUDNN
安装NVIDIA需要先禁用系统自带的驱动,打开文件
sudo gedit /etc/modprobe.d/blacklist.conf
在文本末尾添加以下语句并保存
blacklist nouveau
optionnouveau modeset=0
再执行
sudo update-initramfs -u
lsmod | grep nouveau
没有任何输出说明禁用成功
- 前往官网下载显卡驱动
下载对应版本的.run文件,然后进入下载文件夹,给该文件赋权限
sudo chmod +x NVIDIA-Linux-x86_64-515.57.run
再安装gcc,最后执行安装
sudo apt-get install gcc
sudo ./NVIDIA-Linux-x86_64-515.57.run
安装完成后,可通过以下指令查看是否安装成功,若显示显卡信息,即成功
nvidia-smi
- 下载CUDA 10.2
wget https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run
下载CUDA 10.2补丁包,链接1 链接2 顺序安装 CUDA 10.2 及补丁包 1、2
首先对三个文件赋权限
sudo chmod +x cuda_10.2.89_440.33.01_linux.run
sudo chmod +x cuda_10.2.1_linux.run
sudo chmod +x cuda_10.2.2_linux.run
随后进行安装
sudo ./cuda_10.2.89_440.33.01_linux.run
sudo ./cuda_10.2.1_linux.run
sudo ./cuda_10.2.2_linux.run
cuda配置
sudo gedit ~/.bashrc
在文件末尾添加以下路径:
export CUDA_HOME=/usr/local/cuda-10.2
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH
export PATH=/usr/local/cuda-10.2/bin:$PATH
在终端运行
source ~/.bashrc
查看cuda版本:
nvcc -V
CUDA卸载:进入 /usr/local/cuda-10.2/bin 运行
cuda-uninstaller
- 安装cudnn (实际为复制文件到指定CUDA路径)
下载CUDNN,并解压
tar -xvf cudnn-linux-x86_64-8.4.0.27_cuda10.2-archive.tar.xz
cd cudnn-linux-x86_64-8.4.0.27_cuda10.2-archive
复制CUDNN文件到CUDA路径
sudo cp include/cudnn* /usr/local/cuda-10.2/include
sudo cp lib/cudnn* /usr/local/cuda-10.2/lib64/ -d
给文件赋权限
sudo chmod a+r /usr/local/cuda-10.2/include/cudnn*
sudo chmod a+r /usr/local/cuda-10.2/lib64/libcudnn*
查看CUDNN版本
cat /usr/local/cuda-10.2/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
输出为
--
说明CUDNN版本为8.4.0,安装完成
7、安装python,并将python默认版本更改为python3.6, 并安装pip
sudo apt-get install python
安装完成查看python版本
python -V
若显示 Python 2.7.17, 则需要将默认版本替换为3.6,,首先安装python3.6
sudo apt-get install python3.6
再进行以下设置
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
再次查看python版本
python -V
显示 Python 3.6.9, 配置完成,并安装pip
sudo apt install python-pip
pip升级更新
python3 -m pip install --upgrade pip
若pip安装后无法使用,对pip进行修复
python -m ensurepip
若进一步提示/usr/bin/python: No module named ensurepip
curl https://bootstrap.pypa.io/pip/3.6/get-pip.py -o get-pip.py
python get-pip.py
执行get-pip.py时提示No module named ‘distutils.cmd’
sudo apt-get install python3-distutils
Ubuntu server使用
1、Ubuntu与Xshell建立连接,提示/usr/bin/xauth: file /home/xxx/.Xauthority does not exist
错误原因:添加用户时没有授权对应的目录
解决:
sudo chown xxx:xxx -R home/xxx
2、sudo apt update时出现 Some index files failed to download. They have been ignored, or old ones used instead
sudo su
vim /etc/resolv.conf
添加 nameserver 8.8.8.8 ,保存后再运行
sudo apt update
3、Ubuntu桌面风格、布局等修改
安装unity-tweak-tool工具
sudo apt-get install unity-tweak-tool
安装完成后打开
unity-tweak-tool
若提示 The following schema is missing com.canonical.notify-osd, 运行
sudo apt-get install notify-osd
若提示 The following schema is missing com.canonical.notify-osd(com.canoical.unity.webapps),运行
sudo apt-get install unity-webapps-common
安装gnome-tweak-tool
sudo apt-get install gnome-tweak-tool
完成安装后可在所有应用中找到tweak,打开设置桌面风格、布局等
4、anaconda安装和使用
下载anaconda,并给文件赋权限
sudo chmod +x Anaconda3-2022.05-Linux-x86_64.sh
一路enter,到默认安装位置键入yes,Do you wish the installer to initialize Anaconda3 by running conda init? 这里选择yes,会将conda写入配置文件,再执行以下语句生效
source ~/.bashrc
创建虚拟环境,指定python版本为3.6, 虚拟环境名为python36
conda create -n python36 python=3.6
若提示NoWritableEnvsDirError: No writeable envs directories configured. 进入anaconda的父文件夹,即home
sudo chmod a+w .conda
sudo chmod a+w anaconda3
未完待续…同步更新在我的个人博客:看这里
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)