Problem Description
在vscode中想用命令行执行代码:
python train.py --gpu_ids 0 --name ft_ResNet50 --train_all --batchsize 32 --data_dir your_data_path
The result is shown as follows:
The vscode operating environment is correct, there is torch in this environment, but the command line shows that there is no torch in the current environment.
Cause Analysis:
try 1
I try to enter directly on the vscode command line and
python
the result is as follows. This python3.8 is in the base environment (my pytorch environment python version is 3.9)
try 2
I thought that my environment should be different, so I tried to activate the environment on the command line.
conda activate pytorch_gpu
Trying to enter again
python
failed. The result is still the python version in the base environment.
solution:
The problem is whether the terminal is shell or cmd
Select cmd in this place, and the command line appears as follows.
That's it, the name of the environment appears in front of it.