gpt4 book ai didi

python - 如何在 Singularity 配方中激活 Anaconda 环境

转载 作者:行者123 更新时间:2023-12-03 17:14:10 38 4
gpt4 key购买 nike

我正在尝试创建一个奇点图像和配方,它将创建一个 anaconda 环境,然后激活所述环境,以便我可以在该环境中构建项目的 python 轮,以便在奇点构建完成后它 100% 安装并正常运行。

Bootstrap: docker
From: nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04

%environment

# use bash as default shell
SHELL=/bin/bash

# add CUDA paths
CPATH="/usr/local/cuda/include:$CPATH"
PATH="/usr/local/cuda/bin:$PATH"
LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"
CUDA_HOME="/usr/local/cuda"

# add Anaconda path
PATH="/usr/local/anaconda3/bin:$PATH"

export PATH LD_LIBRARY_PATH CPATH CUDA_HOME
export MKL_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1

%setup
# runs on host
# the path to the image is $SINGULARITY_ROOTFS

%post
# post-setup script

# load environment variables
. /environment

# use bash as default shell
echo "\n #Using bash as default shell \n" >> /environment
echo 'SHELL=/bin/bash' >> /environment

# make environment file executable
chmod +x /environment

# default mount paths
mkdir /scratch /data

#Add CUDA paths
echo "\n #Cuda paths \n" >> /environment
echo 'export CPATH="/usr/local/cuda/include:$CPATH"' >> /environment
echo 'export PATH="/usr/local/cuda/bin:$PATH"' >> /environment
echo 'export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"' >> /environment
echo 'export CUDA_HOME="/usr/local/cuda"' >> /environment

# updating and getting required packages
apt-get update
apt-get install -y wget git vim build-essential cmake

# creates a build directory
mkdir build
cd build

# download and install Anaconda
CONDA_INSTALL_PATH="/usr/local/anaconda3"
wget https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh
chmod +x Anaconda3-5.0.1-Linux-x86_64.sh
./Anaconda3-5.0.1-Linux-x86_64.sh -b -p $CONDA_INSTALL_PATH

# download and install CaImAn
git clone https://github.com/flatironinstitute/CaImAn.git
cd CaImAn
conda env create -n caiman -f environment.yml
source activate caiman
pip install .
caimanmanager.py install
source deactivate


%runscript
# executes with the singularity run command
# delete this section to use existing docker ENTRYPOINT command

%test
# test that script is a success

我都试过了 conda activatesource activate并得到相同的错误。
+ source activate caiman
/bin/sh: 41: source: not found
ABORT: Aborting with RETVAL=255
Cleaning up...

这只是我之后必须通过使图像可写来做的事情吗?
那将是下一个默认解决方案,但如果配方可以正常工作,那就太好了。

*编辑1 . activate caiman返回。
+ . activate caiman
+ [[ -n ]]
/bin/sh: 4: /usr/local/anaconda3/bin/activate: [[: not found
+ [[ -n ]]
/bin/sh: 7: /usr/local/anaconda3/bin/activate: [[: not found
+ echo Only bash and zsh are supported
Only bash and zsh are supported
+ return 1
ABORT: Aborting with RETVAL=255
Cleaning up...

*编辑2
通过使用较新版本的 Anaconda,未找到错误消失了。我所做的只是更改了我使用 wget 获得的 Anaconda 发行版,并且我还强制和更新以加倍确定。
# download and install Anaconda
CONDA_INSTALL_PATH="/usr/local/anaconda3"
wget https://repo.continuum.io/archive/Anaconda3-5.3.1-Linux-x86_64.sh
chmod +x Anaconda3-5.3.1-Linux-x86_64.sh
./Anaconda3-5.3.1-Linux-x86_64.sh -b -p $CONDA_INSTALL_PATH
conda update -n base -c defaults conda
pip install --upgrade pip

最佳答案

如果我没有错(这是完全可能的),virtualenv 也会发生同样的情况。

问题是 source 不是命令,请尝试:

. activate caiman

代替
source activate caiman

更新问题后编辑,请检查此 https://github.com/conda/conda/issues/6639您可能想要调查您的 activate 正在做什么(似乎正在寻找不存在的文件)

关于python - 如何在 Singularity 配方中激活 Anaconda 环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55168018/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com