阿里云服务器Ubuntu系统安装配置PyTorch版深度学习环境

因为淋过雨,所以想为你撑把伞~

阿里云服务器Ubuntu系统安装miniconda3

首先跟着沐神的操作:

1. 更新系统

# 更新系统避免冲突
(root) root@jo-mo-lang-ma:~# sudo apt update

2. 安装编译环境,一些必要的编译所需文件

#安装编译环境
(root) root@jo-mo-lang-ma:~# sudo apt install build-essential

3. Python安装:在安装python时,需选用python3.9,避免后续存在库无法调用情况

#安装python3.9
(root) root@jo-mo-lang-ma:~# sudo apt install python3.9

4. 安装Miniconda

接着去到Miniconda官网找到Python3.9对应的包,然后右键复制链接
在miniconda官网找到与python3.9对应的包
复制链接
右键复制安装包链接
使用wget下载安装包

#下载安装包
(root) root@jo-mo-lang-ma:~# wget https://repo.anaconda.com/miniconda/Miniconda3-py39_23.5.2-0-Linux-x86_64.sh

如下图所示
在这里插入图片描述
经过若干时间后便下载到本地了,可使用命令ls -a查看当前文件夹下所有文件

root@jo-mo-lang-ma:~# ls -a
.              .conda        .jupyter                                  .pip              .rpmdb      wget-log    wget-log.5
..             .config       .lesshst                                  .profile          snap        wget-log.1  wget-log.6
.bash_history  d2l-zh        .local                                    .pydistutils.cfg  .ssh        wget-log.2  .zshrc
.bashrc        d2l-zh.zip.6  miniconda3                                Python-3.9.12     .viminfo    wget-log.3
.cache         .ipython      Miniconda3-py39_23.5.2-0-Linux-x86_64.sh  .python_history   .wget-hsts  wget-log.4

在这里插入图片描述
接着直接bash该文件便可开始安装

root@jo-mo-lang-ma:~# bash Miniconda3-py39_23.5.2-0-Linux-x86_64.sh

最后在手动初始化一下

#初始化bash
root@jo-mo-lang-ma:~# ~/miniconda3/bin/conda init bash

在这里插入图片描述

#初始化zsh
root@jo-mo-lang-ma:~# ~/miniconda3/bin/conda init zsh

在这里插入图片描述

阿里云服务器Ubuntu系统打开jupyter notebook

按照沐神的操作演示:

(base) root@jo-mo-lang-ma:~# pip install jupyter d2l torch torchvision

但是发现在后面调用jupyter notebook时无法打开

(base) root@jo-mo-lang-ma:~# jupyter notebook
[I 2023-10-07 08:48:49.317 ServerApp] Package notebook took 0.0000s to import
[I 2023-10-07 08:48:49.326 ServerApp] Package jupyter_lsp took 0.0088s to import
[W 2023-10-07 08:48:49.326 ServerApp] A `_jupyter_server_extension_points` function was not found in jupyter_lsp. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-10-07 08:48:49.331 ServerApp] Package jupyter_server_terminals took 0.0038s to import
[I 2023-10-07 08:48:49.331 ServerApp] Package jupyterlab took 0.0000s to import
[I 2023-10-07 08:48:49.359 ServerApp] Package notebook_shim took 0.0000s to import
[W 2023-10-07 08:48:49.359 ServerApp] A `_jupyter_server_extension_points` function was not found in notebook_shim. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-10-07 08:48:49.359 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2023-10-07 08:48:49.363 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2023-10-07 08:48:49.367 ServerApp] jupyterlab | extension was successfully linked.
[I 2023-10-07 08:48:49.371 ServerApp] notebook | extension was successfully linked.
[I 2023-10-07 08:48:49.580 ServerApp] notebook_shim | extension was successfully linked.
[I 2023-10-07 08:48:49.598 ServerApp] notebook_shim | extension was successfully loaded.
[I 2023-10-07 08:48:49.600 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2023-10-07 08:48:49.601 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2023-10-07 08:48:49.603 LabApp] JupyterLab extension loaded from /root/miniconda3/lib/python3.9/site-packages/jupyterlab
[I 2023-10-07 08:48:49.603 LabApp] JupyterLab application directory is /root/miniconda3/share/jupyter/lab
[I 2023-10-07 08:48:49.603 LabApp] Extension Manager is 'pypi'.
[I 2023-10-07 08:48:49.606 ServerApp] jupyterlab | extension was successfully loaded.
[I 2023-10-07 08:48:49.608 ServerApp] notebook | extension was successfully loaded.
[C 2023-10-07 08:48:49.609 ServerApp] Running as root is not recommended. Use --allow-root to bypass.

然后按照知乎所说进入到bin目录下依然无法正常启动

#进入到conda目录bin文件夹下启动jupyter notebook
(base) root@jo-mo-lang-ma:~# cd miniconda3
(base) root@iZ7xv3dqwfpk20lj3ci93lZ:~/miniconda3# cd bin
(base) root@iZ7xv3dqwfpk20lj3ci93lZ:~/miniconda3/bin# jupyter notebook
[I 2023-10-07 09:05:15.846 ServerApp] Package notebook took 0.0000s to import
[I 2023-10-07 09:05:15.856 ServerApp] Package jupyter_lsp took 0.0086s to import
[W 2023-10-07 09:05:15.856 ServerApp] A `_jupyter_server_extension_points` function was not found in jupyter_lsp. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-10-07 09:05:15.860 ServerApp] Package jupyter_server_terminals took 0.0042s to import
[I 2023-10-07 09:05:15.861 ServerApp] Package jupyterlab took 0.0000s to import
[I 2023-10-07 09:05:15.888 ServerApp] Package notebook_shim took 0.0000s to import
[W 2023-10-07 09:05:15.888 ServerApp] A `_jupyter_server_extension_points` function was not found in notebook_shim. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-10-07 09:05:15.888 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2023-10-07 09:05:15.892 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2023-10-07 09:05:15.896 ServerApp] jupyterlab | extension was successfully linked.
[I 2023-10-07 09:05:15.900 ServerApp] notebook | extension was successfully linked.
[I 2023-10-07 09:05:16.104 ServerApp] notebook_shim | extension was successfully linked.
[I 2023-10-07 09:05:16.121 ServerApp] notebook_shim | extension was successfully loaded.
[I 2023-10-07 09:05:16.124 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2023-10-07 09:05:16.125 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2023-10-07 09:05:16.126 LabApp] JupyterLab extension loaded from /root/miniconda3/lib/python3.9/site-packages/jupyterlab
[I 2023-10-07 09:05:16.126 LabApp] JupyterLab application directory is /root/miniconda3/share/jupyter/lab
[I 2023-10-07 09:05:16.127 LabApp] Extension Manager is 'pypi'.
[I 2023-10-07 09:05:16.130 ServerApp] jupyterlab | extension was successfully loaded.
[I 2023-10-07 09:05:16.132 ServerApp] notebook | extension was successfully loaded.
[C 2023-10-07 09:05:16.133 ServerApp] Running as root is not recommended. Use --allow-root to bypass.

最后在Youtube上找到一位阿三哥的视频才解决

#设置jupyter notebook允许在root下运行
(base) root@jo-mo-lang-ma:~# jupyter notebook --allow-root
[I 2023-10-07 09:30:10.343 ServerApp] Package notebook took 0.0000s to import
[I 2023-10-07 09:30:10.352 ServerApp] Package jupyter_lsp took 0.0086s to import
[W 2023-10-07 09:30:10.352 ServerApp] A `_jupyter_server_extension_points` function was not found in jupyter_lsp. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-10-07 09:30:10.356 ServerApp] Package jupyter_server_terminals took 0.0037s to import
[I 2023-10-07 09:30:10.357 ServerApp] Package jupyterlab took 0.0000s to import
[I 2023-10-07 09:30:10.383 ServerApp] Package notebook_shim took 0.0000s to import
[W 2023-10-07 09:30:10.384 ServerApp] A `_jupyter_server_extension_points` function was not found in notebook_shim. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-10-07 09:30:10.384 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2023-10-07 09:30:10.388 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2023-10-07 09:30:10.392 ServerApp] jupyterlab | extension was successfully linked.
[W 2023-10-07 09:30:10.394 JupyterNotebookApp] 'allow_root' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2023-10-07 09:30:10.394 JupyterNotebookApp] 'use_redirect_file' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[I 2023-10-07 09:30:10.397 ServerApp] notebook | extension was successfully linked.
[I 2023-10-07 09:30:10.604 ServerApp] notebook_shim | extension was successfully linked.
[I 2023-10-07 09:30:10.621 ServerApp] notebook_shim | extension was successfully loaded.
[I 2023-10-07 09:30:10.624 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2023-10-07 09:30:10.625 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2023-10-07 09:30:10.626 LabApp] JupyterLab extension loaded from /root/miniconda3/lib/python3.9/site-packages/jupyterlab
[I 2023-10-07 09:30:10.626 LabApp] JupyterLab application directory is /root/miniconda3/share/jupyter/lab
[I 2023-10-07 09:30:10.627 LabApp] Extension Manager is 'pypi'.
[I 2023-10-07 09:30:10.630 ServerApp] jupyterlab | extension was successfully loaded.
[I 2023-10-07 09:30:10.632 ServerApp] notebook | extension was successfully loaded.
[I 2023-10-07 09:30:10.632 ServerApp] Serving notebooks from local directory: /root
[I 2023-10-07 09:30:10.632 ServerApp] Jupyter Server 2.7.3 is running at:
[I 2023-10-07 09:30:10.633 ServerApp] http://localhost:8888/tree?token=1ed9f4b1072faa19f53603e9cbfe80c9c3c7ef4c1abf4b3d
[I 2023-10-07 09:30:10.633 ServerApp]     http://127.0.0.1:8888/tree?token=1ed9f4b1072faa19f53603e9cbfe80c9c3c7ef4c1abf4b3d
[I 2023-10-07 09:30:10.633 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 2023-10-07 09:30:10.637 ServerApp] No web browser found: Error('could not locate runnable browser').
[C 2023-10-07 09:30:10.637 ServerApp] 
    
    To access the server, open this file in a browser:
        file:///root/.local/share/jupyter/runtime/jpserver-112031-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/tree?token=1ed9f4b1072faa19f53603e9cbfe80c9c3c7ef4c1abf4b3d
        http://127.0.0.1:8888/tree?token=1ed9f4b1072faa19f53603e9cbfe80c9c3c7ef4c1abf4b3d
[I 2023-10-07 09:30:10.656 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值