远程服务器简略指南




1. 远程登录

Linux的远程登录使用SSH

  • Windows连SSH用MobaXterm,可直接拖文件传到服务器,保持远程连接:Settings→勾选SSH keepalive

MobaXterm

在这里插入图片描述

PS:若是内网,需要先连VPN




2. pip使用清华镜像

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple x --user




3. tensorflow相关

  1. 查看CUDA和cuDNN
    cat /usr/local/cuda/version.txt
    cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
  2. pip安装tensorflow-gpu
    pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==1.4 --user
  3. 测试代码
import tensorflow as tf

a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
print(sess.run(c))  # 看使用的是CPU还是GPU
a: (Const): /job:localhost/replica:0/task:0/device:GPU:0
b: (Const): /job:localhost/replica:0/task:0/device:GPU:0
[[22. 28.]
 [49. 64.]]
  1. 查看GPU使用情况nvidia-smi




扫描二维码关注公众号,回复: 11402429 查看本文章

4. Python含中文注释无法运行

程序头加上

#!/usr/bin/python
#!-*-coding:UTF8-*-




5. 压缩、解压命令zip

压缩:zip -r mydata.zip mydata

解压:unzip -o -d ./ file.zip

压缩所有mp4文件:zip -r a.zip *.mp4




6. 安装Jupyter notebook

安装火狐浏览器

yum install firefox

安装Jupyter notebook

pip install jupyter

pip install jupyter_contrib_nbextensions

jupyter contrib nbextension install --user

pip install yapf

进入jupyter notebook后发现Nbextensions

  • Code prettify:代码格式化
  • Collapsible Headings:折叠Headings区域
  • ScrollDown:输出过长时,自动下拉滚动条
  • Table of Contents (2):根据Markdown的标题栏自动生成目录
  • Codefolding:折叠代码块




7. Git

  1. 安装Git yum install git

  2. 查看版本 git --version

  3. 生成SSH密钥:ssh-keygen -t rsa -C 你的邮箱 →回车→打开id_rsa.pub→添加到GitLab的SSH Keys中
    在这里插入图片描述
    在这里插入图片描述

  4. 克隆项目 git clone xxx.git

PS:如果GitLab是内网自建的话,外网要操作的话要映射到外网




8. 后台启动脚本nohup

后台启动:
nohup 具体命令 &

输出默认保存到nohup.out
nohup python3 -u xxx.py &

保存输出:
nohup python3 -u xxx.py > /tmp/test.log &

后台启动脚本命令nohup返回pid

显示当前终端任务:jobs

结束进程:kill 某pid

查看端口占用情况ss -nlpt | grep 某端口




9. 前端报错net::ERR_CONNECTION_REFUSED

前端发送请求到http://localhost:8080改成http://本机IP:8080




参考文献

  1. SSH原理与运用(一):远程登录
  2. Python pip使用国内镜像安装第三方库:命令行或Pycharm
  3. 从GitLab clone项目到本地
  4. permission denied (publickey)的解决方法
  5. linux-root用户可以git clone,但普通用户就不能git clone
  6. Linux网络状态工具ss命令使用详解

猜你喜欢

转载自blog.csdn.net/lly1122334/article/details/88667123