有时候需要设置下临时路径以方便使用,在逛github FCOS配置的时候看到了这种使用方式,觉得蛮有用的,分享给大家:
export INSTALL_DIR=$PWD
# install pycocotools
cd $INSTALL_DIR
git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
python setup.py build_ext install
# install cityscapesScripts
cd $INSTALL_DIR
git clone https://github.com/mcordts/cityscapesScripts.git
cd cityscapesScripts/
python setup.py build_ext install
# install apex
cd $INSTALL_DIR
git clone https://github.com/NVIDIA/apex.git
cd apex
python setup.py install --cuda_ext --cpp_ext
# install PyTorch Detection
cd $INSTALL_DIR
git clone https://github.com/facebookresearch/maskrcnn-benchmark.git
cd maskrcnn-benchmark
# the following will install the lib with
# symbolic links, so that you can modify
# the files if you want and won't need to
# re-build it
python setup.py build develop
unset INSTALL_DIR
看到了吗,就是预先设置一个临时的环境变量,过后再删掉:
export INSTALL_DIR=$PWD # 设置 INSTALL_DIR 为当前工作路径
cd $INSTALL_DIR # 加个 $ 就可以直接当做路径用
unset INSTALL_DIR # 最后再取消就可