在AWS上搭建JupyterLab

雪域幽狐 2020-07-23 11:31 阅读:7636


启动EC2

AMI选择Deep Learning AMI (Amazon Linux 2)。
实例类型选择GPU实例,这个后期也可以修改。
配置实例时自动分配公有IP记得选择启用。
存储至少需要100GiB。
选择合适的安全组,后续需要用到8888端口。

安装、设置JupyterLab

ssh登录EC2
下载安装jupyterlab
pip install jupyterlab
修改Jupyter密码
jupyter notebook password
配置JupyterLab
运行jupyter lab --generate-config可看到当前配置文件路径。
## 服务的端口,用默认的8888即可
c.NotebookApp.port = 8888
 
## 是否需要自动弹出浏览器,服务器端一般不需要
c.NotebookApp.open_browser = False
 
## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = '/home/ec2-user'

##  client ip 限制 
c.NotebookApp.ip='*'
启动
jupyter-lab  &
登录web
浏览器访问http://ip:8888/lab,第一次较慢。

验证GPU是否可用

选择tensorflow2_p37 kernel,然后运行以下代码:
import tensorflow as tf
print("tf.config.list_physical_devices('GPU'):"+str(tf.config.list_physical_devices('GPU')))
print("tf.test.is_built_with_cuda():"+str(tf.test.is_built_with_cuda()))

如果支持GPU,输出
tf.config.list_physical_devices('GPU'):[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
tf.test.is_built_with_cuda():True

0条评论

登陆后可评论