That’s not completely  true. It works setting the variable inside the python script. But it has to be set before the first import of pytorch or other modules using pytorch (and other kinds of GPU-processing as in other DL_libraries like keras or tensorflow).
At least this is what I experienced on a GPU-Cluster running Linux. On Windows however this seems to work only in some cases