For what it’s worth, I recommend trying this in a clean virtual (or physical) machine. I haven’t tried to build PyTorch recently in Ubuntu 17.04, but I did recently struggle with Ubuntu 16.04, and I can confirm that the following sequence works:
Install anaconda 5
Activate it (eg “. anaconda3/bin/activate” - don’t forget the dot before the command)
sudo apt-get install g++ cmake
conda install numpy pyyaml mkl setuptools cffi
git clone https://github.com/pytorch/pytorch.git
cd pytorch
python setup.py install

Close your terminal and open a new one.
You should now be able to import pytorch