Linux服务器常用命令 - 记录(Anaconda/Matlab/VNC/Python)

这篇博客记录了在Linux服务器中常用的管理操作,包括VNC的使用,查看GPU状态,conda环境的创建、激活和删除,以及PyTorch在GPU上的配置问题。博主遇到并解决了PyTorch与CUDA版本不兼容导致的Python崩溃问题,最终成功在CUDA 11.1上运行PyTorch 1.9。

前言

记录自己常用的指令

VNC

Host XXX
HostName xxx.xx.xx.xx (IP 地址)
LocalForward 59xx(本地编号) 127.0.0.1:59xx(端口号)
User xxxx
vncserver :99 
vncserver -localhost -geometry 1920x1080 :99
vncserver -kill :99

查看当前状态

当前用户占用的端口号
vncserver -list

所有用户的端口号
ps -ef | grep vnc

初次运行需要创建密码

使用TightVNC Viewer 或者 RealVNC 进行远程连接
localhost:03 (03是自己给不同服务器定义的编号 = 127.0.0.1:59xx)

查看当前运行的matlab进程(MATLAB 崩溃后没有释放显存?)
Python一样 Pytorch训练中途意外退出,显存没有被释放

ps -ef | grep MATLAB
kill -9 xxxxxx

共享粘贴板

vncconfig -nowin&

GPU

查看GPU的利用

nvidia-smi
Mon Aug 15 15:18:31 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.73.08    Driver Version: 510.73.08    CUDA Version: 11.6     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+===============
Linux 系统使用 Conda 安装 Python 3.6 出现 `Solving environment: failed` 和 `PackagesNotFoundError` 可尝试以下解决办法: - **切换 Python 版本**:若在激活虚拟环境后切换过 Python 版本,可将 Python 切换回默认版本。例如将 Python 切换回默认的 2.7,Python 3 切换回 3.5,使用如下命令: ```bash sudo update-alternatives --config python sudo update-alternatives --config python3 ``` 执行 `sudo update-alternatives --config python` 可能会出现类似如下输出: ```plaintext 有 3 个候选项可用于替换 python (提供 /usr/bin/python)。 选择 路径 优先级 状态 ------------------------------------------------------------ 0 /usr/bin/python2.7 1 自动模式 1 /home/mrips/anaconda3/envs/py36/bin/python3.6 1 手动模式 * 2 /usr/bin/python2.7 1 手动模式 3 /usr/bin/python3.5 1 手动模式 ``` 执行 `sudo update-alternatives --config python3` 可能会出现类似如下输出: ```plaintext 有 2 个候选项可用于替换 python3 (提供 /usr/bin/python3)。 选择 路径 优先级 状态 ------------------------------------------------------------ 0 /home/mrips/anaconda3/envs/py36/bin/python3.6 1 自动模式 * 1 /home/mrips/anaconda3/envs/py36/bin/python3.6 1 手动模式 2 /usr/bin/python3.5 1 手动模式 ``` 根据输出选择合适的 Python 版本 [^1]。 - **检查环境配置文件**:若使用 `conda env create -f environment.yml` 命令创建环境,环境配置文件是从其他机器导出的,文件里的软件包是按照导出文件的机器配置的,可能会导致找不到包。需要检查并调整配置文件内容 [^2]。 - **使用 conda-forge 源**:使用 conda-forge 源来安装软件包,可能会解决依赖问题。命令如下: ```bash conda config --add channels conda-forge conda install -n your_env_name python=3.6 ``` 这里 `your_env_name` 为你的环境名称 [^3]。 - **添加国内镜像源**:在创建环境之前,添加国内镜像源,可选择清华源或中科大源等。以清华源为例,修改 Conda 配置文件 `.condarc`,内容如下: ```plaintext channels: - defaults show_channel_urls: true default_channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 custom_channels: conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud ``` 修改后,Conda 会按照新的配置来寻找软件包 [^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值