欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

docker配置pytorch環(huán)境來進(jìn)行訓(xùn)練的方法步驟

 更新時(shí)間:2024年03月12日 11:30:41   作者:GY—Monkey  
本文主要介紹了docker配置pytorch環(huán)境來進(jìn)行訓(xùn)練的方法步驟,從零開始配置,包括換源,安裝下載,具有一定的參考價(jià)值,感興趣的可以了解一下

一、虛擬環(huán)境anaconda的下載與安裝(換源)

進(jìn)入到虛擬環(huán)境

docker exec -it ID

新建一個(gè)文件夾保存下載的文件

mkdir download

通過使用wget來下載anacodna安裝包,建議使用清華鏡像下載
官網(wǎng)下載:

wget https://repo.anaconda.com/archive/Anaconda3-2023.07-2-Linux-x86_64.sh

鏡像下載:

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2023.07-1-Linux-x86_64.sh

本地宿主機(jī)復(fù)制到容器中(修改路徑即可)

docker cp /path/to/local/file container_id:/path/in/container/

安裝應(yīng)用

bash Anaconda3-2023.07-1-Linux-x86_64.sh

按照流程進(jìn)行安裝
確認(rèn)協(xié)議和默認(rèn)安裝路徑即可

在這里插入圖片描述

二、給系統(tǒng)的pip和conda換源

安裝新系統(tǒng)的第一件事情就是換源,加快下載速度

1.pip換源

docker中安裝pip

apt-get update
apt-get install -y python3-pip

驗(yàn)證安裝的結(jié)果

pip3 --version

/root/目錄下創(chuàng)建 .pip 文件夾與 pip.conf 文件

mkdir .pip
vim .pip/pip.conf
## 添加如下內(nèi)容,設(shè)置pip源為阿里云源
 
[global] 
index-url = https://mirrors.aliyun.com/pypi/simple/ 
[install] 
trusted-host=mirrors.aliyun.com
 
## :wq!保存退出即可

2.conda換源(不建議阿里源)
命令行換源:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
conda config --add https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
conda config --add https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
conda config --add https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
conda config --add https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
conda config --add https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
conda config --add https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
conda config --add https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
conda config --add https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
conda config --set show_channel_urls yes

修改文件方式: .condarc

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
  deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
auto_activate_base: false

三、安裝pytorch

進(jìn)入pytorch的官方網(wǎng)站

找到對(duì)應(yīng)的版本進(jìn)行安裝

https://pytorch.org/get-started/previous-versions/

訓(xùn)練過程中遇到的問題

1、虛擬共享內(nèi)存不夠
報(bào)錯(cuò):ERROR: Unexpected bus error encountered in worker. This might be caused by insufficient shared memor

通過df -h查看shm的大小
可見容器默認(rèn)的shared memory只有64MB。但訓(xùn)練程序中,data_loader設(shè)置的workers數(shù)目比較多,該程序中為8,這些workers通過共享內(nèi)存進(jìn)行協(xié)作,導(dǎo)致默認(rèn)的共享內(nèi)存不夠用。

解決方法:
基于以上原因,解決方法可從兩個(gè)方面入手:

  • 將workers數(shù)量降低,例如設(shè)置num_workers=0;

  • 將容器的共享內(nèi)存加大,由上面英文提示,可通過–ipc=host或–shm-size進(jìn)行設(shè)置。

這里,我選擇的是第二種方式,加大容器的共享內(nèi)存:

docker run ... --shm-size 8G ...

2、數(shù)據(jù)集的加載路徑
建議使用絕對(duì)的路徑,相對(duì)路徑在容器中可能會(huì)報(bào)錯(cuò)

3、報(bào)錯(cuò)內(nèi)容:ImportError: libGL.so.1: cannot open shared object file: No such file or directory。
這通常是因?yàn)槟愕南到y(tǒng)缺少該庫,它是 OpenGL 的一部分,許多圖形相關(guān)的應(yīng)用程序和庫都需要它。

解決方法,安裝相應(yīng)的庫文件

apt-get update && apt-get install libgl1

4、報(bào)錯(cuò)內(nèi)容:ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
解決方法:

sudo apt-get install libglib2.0-0

到此這篇關(guān)于docker配置pytorch環(huán)境來進(jìn)行訓(xùn)練的方法步驟的文章就介紹到這了,更多相關(guān)docker配置pytorch內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家! 

相關(guān)文章

  • docker swarm 集群創(chuàng)建過程

    docker swarm 集群創(chuàng)建過程

    通過docker swarm 工具將一臺(tái)或者多臺(tái)安裝了docker的服務(wù)器組成一個(gè)完整的集群,該集群中的node節(jié)點(diǎn)可以通過Leader節(jié)點(diǎn)管理,這篇文章主要介紹了docker swarm 集群創(chuàng)建,需要的朋友可以參考下
    2024-03-03
  • Idea部署遠(yuǎn)程Docker并配置文件

    Idea部署遠(yuǎn)程Docker并配置文件

    這篇文章給大家介紹Idea部署遠(yuǎn)程Docker并添加配置文件的方法及修改項(xiàng)目pom文件的代碼解析,對(duì)idea部署遠(yuǎn)程docker相關(guān)知識(shí)感興趣的朋友一起看看吧
    2021-06-06
  • Docker鏡像下載的常見問題及解決辦法

    Docker鏡像下載的常見問題及解決辦法

    在使用Docker時(shí),用戶常遇到下載鏡像錯(cuò)誤,如TLS握手超時(shí)、請(qǐng)求取消等,主要由網(wǎng)絡(luò)狀況、配置問題或DockerHub服務(wù)導(dǎo)致,本文就來介紹了一下幾種解決方法,感興趣的可以了解一下
    2024-10-10
  • 10分鐘學(xué)會(huì)docker

    10分鐘學(xué)會(huì)docker

    Docker 是一個(gè)開源的應(yīng)用容器引擎,基于 Go 語言 并遵從Apache2.0協(xié)議開源。Docker 可以讓開發(fā)者打包他們的應(yīng)用以及依賴包到一個(gè)輕量級(jí)、可移植的容器中,然后發(fā)布到任何流行的 Linux 機(jī)器上,也可以實(shí)現(xiàn)虛擬化。
    2017-06-06
  • 如何進(jìn)入、退出docker的container實(shí)現(xiàn)

    如何進(jìn)入、退出docker的container實(shí)現(xiàn)

    這篇文章主要介紹了如何進(jìn)入、退出docker的container實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • Centos7上安裝docker的方法

    Centos7上安裝docker的方法

    Docker從1.13版本之后采用時(shí)間線的方式作為版本號(hào),分為社區(qū)版CE和企業(yè)版EE。這篇文章給大家介紹了Centos7上安裝docker的方法,感興趣的朋友一起看看吧
    2018-07-07
  • Docker與iptables及實(shí)現(xiàn)bridge方式網(wǎng)絡(luò)隔離與通信操作

    Docker與iptables及實(shí)現(xiàn)bridge方式網(wǎng)絡(luò)隔離與通信操作

    這篇文章主要介紹了Docker與iptables及實(shí)現(xiàn)bridge方式網(wǎng)絡(luò)隔離與通信操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-11-11
  • docker 如何添加證書

    docker 如何添加證書

    這篇文章主要介紹了docker 如何添加證書的操作方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2021-03-03
  • 如何修改Docker部署gitlab的外部訪問地址和端口

    如何修改Docker部署gitlab的外部訪問地址和端口

    這篇文章主要介紹了如何修改Docker部署gitlab的外部訪問地址和端口問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • Docker鏡像分析工具dive原理解析

    Docker鏡像分析工具dive原理解析

    這篇文章主要介紹了Docker鏡像分析工具dive原理解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值
    2020-11-11

最新評(píng)論