foreword
First of all, you need to build a running environment on the server, see the previous blog: [ Building a deep learning model running environment on the server: ubuntu ]
This article mainly talks about how to run the open source model when the running environment is set up, using Inf-Net: Automatic COVID -19 Lung Infection Segmentation from CT Images this paper as an example.
I have downloaded the following parts locally and uploaded them to the server folder.
process and problems
-
A MemoryError problem occurs when the second step of downloading is performed ;
solution:pip --no-cache-dir install -r requirements.txt
(Because pip's caching mechanism tries to cache the entire file of the library that you want to install in memory, and in an environment that limits the size of the cache, if the installation package is large, it will This error of MemoryError occurs.
-
It was only when I wrote this that I remembered that I did not install these libraries in the virtual environment !
solution:- First activate the environment:
source activate SINet
(SINet
for the environment name - Note to switch to the folder path:
cd /path
(/path
the path of the file in the server - Then pip will do.
- First activate the environment:
-
Use it when downloading THOP
pip install thop
or it will fail. -
Switch to the corresponding directory when running
python test.py
.
Use XShell to connect to the server and run
Because the previous server did not have a GPU, I changed the server, set up the proxy first, and then used XShell to connect to the server, so the process is described below.
CondaHTTPError: HTTP 000 CONNECTION FAILED for url problem occurs when creating a virtual environment :
- Open the file for editing:
vim ~/.condarc
- click
i
button - Enter something to change
- click
Esc
button - Enter
:wq
to save and exit (:q
exit without saving) - enter
conda clean -i
run code
After downloading the code and dataset, you can start running the code.
Parameter problem :
parser.add_argument()
You can add parameters for command line operation. For detailed usage, see: Python's parser.add_argument() usage - command line options, parameters and subcommands parser
t2.py:
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--aa', type=str, default = None)
parser.add_argument('--bb', type=int, default=32)
args = parser.parse_args()
if(args.bb==3):
print(f'hello world, args.bb={
args.bb}')
else:
print(f'sorry, args.bb is not 3, but ={
args.bb}')
Instructions:
python t2.py --aa=15 --bb=3
python t2.py --aa=15 --bb=10