Permission error on using cpp_extention.py, i am using pytorch v1.6 on docker. anyone have an idea? kindly help

File “/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py”, line 970, in load
build_directory or _get_build_directory(name, verbose),
File “/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py”, line 1454, in _get_build_directory
os.makedirs(build_directory, exist_ok=True)
File “/opt/conda/lib/python3.6/os.py”, line 210, in makedirs
makedirs(head, mode, exist_ok)
File “/opt/conda/lib/python3.6/os.py”, line 210, in makedirs
makedirs(head, mode, exist_ok)
File “/opt/conda/lib/python3.6/os.py”, line 220, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: ‘/.cache’

It seems you don’t have permission to create folders in /, so you could try to create a /workspace folder or any other home folder and see, if Python could write to it. Alternatively you might want to change permissions inside your docker container (but you should be root by default, shouldn’t you?).

Thanks! i solved it with os.environ[‘TORCH_EXTENSIONS_DIR’] = ‘path/to/folder/inside/project’ since the code was not allowed to create folder in /, and the ‘.cache’ folder(which hold pre-trained weights and extentions) is created by default in root