'Vscode - Python Debugger: unrecognized arguments
I'm trying to debug some Python code I have which I can run with no problem by typing the following in bash:
CUDA_VISIBLE_DEVICES=0 \
python test_multi.py \
--experiment_name 128_shortcut1_inject1_none \
--test_atts Eyeglasses \
--test_ints -1.0
I've created this json config file for VScode:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "<absolute_path>/test_multi.py",
"console": "integratedTerminal",
"env": [{ "name":"CUDA_VISIBLE_DEVICES", "value":0}],
"args": ["--experiment_name 128_shortcut1_inject1_none", "--test_atts Eyeglasses", "--test_ints -1"]
}
]
}
but I keep gettingtest_multi.py: error: unrecognized arguments: --experiment_name 128_shortcut1_inject1_none --test_atts Eyeglasses --test_ints -1
Solution 1:[1]
I was looking at this thread to see how I could use CUDA_VISIBLE_DEVICES in env and the way you wrote it down, here:
"env": [{ "name":"CUDA_VISIBLE_DEVICES", "value":0}]
, didn't work for me. I had to correct it to:
"env": {"name":"CUDA_VISIBLE_DEVICES", "value":"0"}
I imagine the []- brackets are only expected when you have more then one entry?
Solution 2:[2]
The way Brett shows didn't work with my case. I want to use the Number "1" GPU for debugging, so I added
"env": {"CUDA_VISIBLE_DEVICES":"1"}, to the launcher.json file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bochjamin |
| Solution 2 | Robin Li |
