当前位置:网站首页>腾讯云GPU最佳实践-使用jupyter pycharm远程开发训练
腾讯云GPU最佳实践-使用jupyter pycharm远程开发训练
2022-04-23 18:54:00 【大鹅】
背景
作为炼丹工程师,GPU毫无疑问会给我们训练模型带来极高的效率提升,但是一般实际开发都是本地编写然后复制代码到GPU机器上面运行,这样效率就会有一定的折损,而且同时维护两套环境可能还会偶尔会有报错。那么为什么我们不直接远程到GPU机器上直接进行开发呢?
本文将主要讲述几个常用的远程开发方法,总有一个是适合你的。
- GPU机器与环境准备
- jupyter notebook远程
- 本地pycharm远程jupyter开发
- 远程pycharm
1. GPU机器与环境准备
https://cloud.tencent.com/product/gpu
首先在选购一台GPU机器,可以看需求可选择计算型或者GPU推理型;
在选择镜像的时候,如果有GPU驱动预安装可以优先选择,可免去安装驱动的繁杂流程:
这里选择使用GPU计算型+CentOS 7.6 作为示范:
如果没有GPU驱动预安装选项,只好我们自己手动安装了,可参考下列文档:
https://cloud.tencent.com/document/product/560/8048
https://cloud.tencent.com/developer/article/1835925
2. jupyter notebook远程
Jupyter Notebook简介
- Jupyter Notebook是一款开源的Web应用,类似于Web笔记本,我们可以使用它编写代码、公式、Markdown解释性文本和绘图,并且可以把创建好的文档进行分享。
- Jupyter Notebook最为方便的功能在于其可以实时运行代码,并且返回代码段的运行结果,支持可视化、IDE等能力,大大提高了模型搭建和分析的效率。
- 目前已经广泛应用于数据处理、数据模拟、统计建模、机器学习等重要领域。
2.1 安装
pip3 install jupyter
2.2 生成一个 notebook 配置文件
jupyter notebook --generate-config
执行后会生成配置文件, ~/.jupyter/jupyter_notebook_config.py
2.3 设置密码
$ jupyter notebook password
Enter password: ****
Verify password: ****
[NotebookPasswordApp] Wrote hashed password to ~/.jupyter/jupyter_notebook_config.json
2.4 修改配置
修改jupyter_notebook_config.py
c.NotebookApp.ip='192.168.0.1'
c.NotebookApp.password = u'sha:ce...刚才复制的那个密文'
c.NotebookApp.open_browser = False#启动服务后不打开浏览器
c.NotebookApp.port =8888 #可自行指定一个端口, 访问时使用该端口
The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = '/'##将启动目录设置为/
2.5 后台运行
nohup jupyter notebook --allow-root > jupyter.log 2>&1 &
启动后,即可进入公网IP进行远程开发了(记得打开GPU机器网络白名单)
此时运行notebook是直接在GPU上面运行,所以也不用担心消耗本地资源,也无需本地运行后放在GPU机器上来回折腾了。
3. 本地pycharm远程jupyter开发
这个时候其实已经实现了远程开发,但是估计还会有不少小伙伴觉得现在直接用网页进行开发不少很习惯,没有了IDE的hint,也不知道库里面有什么方法,怎么调用,这个时候我们就可以使用IDEA pycharm进行远程开发。
1. 首先下载pycharm专业版(社区版没有jupyter功能) https://www.jetbrains.com/zh-cn/pycharm/
2. 进入pycharm后,在设置里面找到jupyter notebook服务器,选择第二个配置的服务输入我们第一步外网的jupyter链接;
3. 为了让GPU服务器的Python lib版本与本地一致,且本地可以不下载这么多lib,我们可以配置远程python解释器:这么一来本地机器甚至连Python都不用安装,大大解放存储空间;
在pycharm设置离找到项目的Python解释器,新建一个解释器,输入GPU服务器公网IP与ssh端口进行远程连接:
4. 设置完成后,就可以使用本地的pycharm连上GPU机器进行训练开发了;
4. 远程pycharm
最后一节,如果还有小伙伴觉得本地安装一个pycharm,实在是太占空间了,有没有办法可以本地pycharm都不使用呢?
是有的,projector,直接在GPU机器上面安装pycharm,远程web开发;
1. 安装python3、python3-pip:
yum install -y python3 python3-pip
2. 安装依赖库文件:
yum install libxext6 libxrender1 libxtst6 libfreetype6 libxi6
3. pip安装projector
pip3 install --upgrade pip
pip3 install projector-installer
每次运行projector前执行
export LC_ALL=en_US.utf-8
export LANG=en_US.utf-8
(注意:第一次运行projector,可能会提示projector : command not found,将/usr/local/bin/projector 加入环境变量即可)
4. 安装pycharm
projector install
4. 配置projector
执行 projector config edit 进行配置修改,添加projector -server 服务
5. 运行
projector run
执行会生成URL,换成公网IP后即可远程开发了。
Ref
1. projector https://github.com/JetBrains/projector-installer
2. https://blog.jetbrains.com/zh-hans/blog/2021/03/25/projector-ide/
版权声明
本文为[大鹅]所创,转载请带上原文链接,感谢
https://cloud.tencent.com/developer/article/1986131
边栏推荐
- Using bafayun to control the computer
- Scrollto and scrollby
- The first leg of the national tour of shengteng AI developer creation and enjoyment day was successfully held in Xi'an
- Use bitnami / PostgreSQL repmgr image to quickly set up PostgreSQL ha
- Tangle
- ctfshow-web362(SSTI)
- 深入理解 Golang 中的 new 和 make 是什么, 差异在哪?
- Chondroitin sulfate in vitreous
- Usage of functions decode() and replace() in SQL
- About the operation of unit file reading (I)
猜你喜欢
Summary of actual business optimization scheme - main directory - continuous update
ESP32 LVGL8. 1 - arc (arc 19)
Simplified path (force buckle 71)
Use bitnami / PostgreSQL repmgr image to quickly set up PostgreSQL ha
微搭低代码零基础入门课(第三课)
玻璃体中的硫酸软骨素
PyGame tank battle
MVVM模型
12个例子夯实promise基础
剑指 Offer II 116. 省份数量-空间复杂度O(n),时间复杂度O(n)
随机推荐
【科普】CRC校验(一)什么是CRC校验?
ESP32 LVGL8. 1 - checkbox (checkbox 23)
ESP32 LVGL8. 1 - msgbox message box (msgbox 28)
剑指 Offer II 116. 省份数量-空间复杂度O(n),时间复杂度O(n)
[popular science] CRC verification (I) what is CRC verification?
2022.04.23(LC_763_划分字母区间)
Druid SQL和Security在美团点评的实践
Introduction to micro build low code zero Foundation (lesson 3)
数据库上机实验四(数据完整性与存储过程)
Practice of Druid SQL and security in meituan review
Dynamically add and delete layouts
How to virtualize the video frame and background is realized in a few simple steps
#yyds干货盘点#stringprep --- 因特网字符串预备
Teach you to quickly rename folder names in a few simple steps
Minesweeping II of souI instance
视频边框背景如何虚化,简单操作几步实现
简化路径(力扣71)
ESP32 LVGL8. 1 - img picture (IMG 20)
Nacos作为服务注册中心
Xlslib use