I’m not familiar with CentOS and googling for this error only showed some error related to macOS.
Were you able to call this code before, i.e. did you change something in your setup?
Is the GPU recognized and were you able to run CUDA examples?
Also, could you try to update PyTorch? Version 0.4.0 is quite old by now so maybe this issue has been already fixed.