it shouldn’t be inside the python script but to be set as an enviroment variable in the console such as
CUDA_VISIBLE_DEVICES=0,1 python your_script.py
Note that you SHOUDLN’T t set it as a permanent enviroment variable in the bashrc as it affects the whole system.