POSTS
A verification of "Fast StyleTransfer" using TensorFlow 1.3 on ROCm with AMD Radeon Vega 56
Introduction
Source | Style Transfer |
---|---|
This time, I am going to run the “Style transfer” which is popular in the field of image generation and image style transfer, using Tensorflow 1.3 on ROCm with AMD Radeon Vega56.
System requirements
AMD(TF1.3): Ubuntu 16.04.4 x64 TensorFlow 1.3 Python 3.5 Driver: ROCm 1.7.137
I used the following source code of Fast StyleTransfer when performing. https://github.com/lengstrom/fast-style-transfer.git
Thank you,Logan Engstrom.
Setup TensorFlow on Radeon GPU
HIP-TensorFLow 1.0.1 was recently updated to TensorFlow 1.3, with HIP being removed and made into its own repository at the same time. As a result, the old HIP-TensorFlow repository is no longer viewable. https://github.com/ROCmSoftwarePlatform/hiptensorflow
We were unsure what to call the new TensorFlow, so we settled on ROCm-TensorFlow. https://github.com/ROCmSoftwarePlatform/tensorflow
The following commands allow one to easily build ROCm-TensorFlow 1.3 in Python3. This includes OpenCV 3.3.0, video codecs, and Cython or Pillow images.
curl -sL http://install.aieatr.com/setup_rocm_tensorflow_p3
[Ubuntu16.04]
Fast Style Transfer
Clone the repository of fast-style-transfer and install required packages. There is a part loading the video conversion module inside, so moviepy needs to be installed via pip3.
git clone https://github.com/lengstrom/fast-style-transfer.git
sudo pip3 install moviepy
Obtain the following trained model as written in the Readme. Google Drive - udnie.ckpt
Make a directory for styles
mkdir -p fast-style-transfer/styles
Store the trained model under the directory. fast-style-transfer/styles/udnie.ckpt
Execution
Execute evaluate.py with the trained module “udnie.ckpt”. and test images which are stored in the fast-style-transfer/examples/content
python3 evaluate.py --checkpoint styles/udnie.ckpt --in-path examples/content/chicago.jpg --out-path output.jpg --allow-different-dimensions
johndoe@sonoba:~/projects/fast-style-transfer$ python3 evaluate.py --checkpoint styles/udnie.ckpt --in-path examples/content/chicago.jpg --out-path output.jpg
2018-04-16 00:42:46.922074: W tensorflow/stream_executor/rocm/rocm_driver.cc:405] creating context when one is currently active; existing: 0x7f6d67384a80
2018-04-16 00:42:46.922178: I tensorflow/core/common_runtime/gpu/gpu_device.cc:907] Found device 0 with properties:
name: Device 687f
AMDGPU ISA: gfx900
memoryClockRate (GHz) 1.622
pciBusID 0000:04:00.0
Total memory: 7.98GiB
Free memory: 7.73GiB
2018-04-16 00:42:46.922194: I tensorflow/core/common_runtime/gpu/gpu_device.cc:929] DMA: 0
2018-04-16 00:42:46.922200: I tensorflow/core/common_runtime/gpu/gpu_device.cc:939] 0: Y
2018-04-16 00:42:46.922208: I tensorflow/core/common_runtime/gpu/gpu_device.cc:997] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Device 687f, pci bus id: 0000:04:00.0)
2018-04-16 00:42:47.295424: I tensorflow/core/kernels/conv_ops.cc:670] running auto-tune for Convolve
MIOpen(HIP): Warning [FindRecordUnsafe] File is unreadable: /opt/rocm/miopen/share/miopen/db/gfx900_56.cd.pdb.txt
2018-04-16 00:42:47.591796: I tensorflow/core/kernels/conv_ops.cc:670] running auto-tune for Convolve
2018-04-16 00:42:47.690422: I tensorflow/core/kernels/conv_ops.cc:670] running auto-tune for Convolve
2018-04-16 00:42:47.746517: I tensorflow/core/kernels/conv_ops.cc:670] running auto-tune for Convolve
2018-04-16 00:42:47.753080: I tensorflow/core/kernels/conv_grad_input_ops.cc:858] running auto-tune for Backward-Data
MIOpen(HIP): Warning [FindRecordUnsafe] File is unreadable: /opt/rocm/miopen/share/miopen/db/gfx900_56.cd.pdb.txt
2018-04-16 00:42:47.835384: I tensorflow/core/kernels/conv_grad_input_ops.cc:858] running auto-tune for Backward-Data
MIOpen(HIP): Warning [FindRecordUnsafe] File is unreadable: /opt/rocm/miopen/share/miopen/db/gfx900_56.cd.pdb.txt
2018-04-16 00:42:47.897467: I tensorflow/core/kernels/conv_ops.cc:670] running auto-tune for Convolve
MIOpen(HIP): Warning [FindRecordUnsafe] File is unreadable: /opt/rocm/miopen/share/miopen/db/gfx900_56.cd.pdb.txt
The output is below. fast-style-transfer/output/output.jpg
In case you want different styles, then you could bring other trained models, e.g., wave.ckpt. Google Drive - wave.ckpt
Execute it as below.
python3 evaluate.py --checkpoint styles/wave.ckpt --in-path examples/content/chicago.jpg --out-path output.jpg --allow-different-dimensions
johndoe@sonoba:~/projects/fast-style-transfer$ python3 evaluate.py --checkpoint styles/wave.ckpt --in-path examples/content/chicago.jpg --out-path output.jpg
2018-04-16 00:43:40.259885: W tensorflow/stream_executor/rocm/rocm_driver.cc:405] creating context when one is currently active; existing: 0x7f37ff404050
2018-04-16 00:43:40.259977: I tensorflow/core/common_runtime/gpu/gpu_device.cc:907] Found device 0 with properties:
name: Device 687f
AMDGPU ISA: gfx900
memoryClockRate (GHz) 1.622
pciBusID 0000:04:00.0
Total memory: 7.98GiB
Free memory: 7.73GiB
2018-04-16 00:43:40.259993: I tensorflow/core/common_runtime/gpu/gpu_device.cc:929] DMA: 0
2018-04-16 00:43:40.259999: I tensorflow/core/common_runtime/gpu/gpu_device.cc:939] 0: Y
2018-04-16 00:43:40.260007: I tensorflow/core/common_runtime/gpu/gpu_device.cc:997] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Device 687f, pci bus id: 0000:04:00.0)
2018-04-16 00:43:40.634307: I tensorflow/core/kernels/conv_ops.cc:670] running auto-tune for Convolve
MIOpen(HIP): Warning [FindRecordUnsafe] File is unreadable: /opt/rocm/miopen/share/miopen/db/gfx900_56.cd.pdb.txt
2018-04-16 00:43:40.893959: I tensorflow/core/kernels/conv_ops.cc:670] running auto-tune for Convolve
2018-04-16 00:43:40.987932: I tensorflow/core/kernels/conv_ops.cc:670] running auto-tune for Convolve
2018-04-16 00:43:41.043334: I tensorflow/core/kernels/conv_ops.cc:670] running auto-tune for Convolve
2018-04-16 00:43:41.049861: I tensorflow/core/kernels/conv_grad_input_ops.cc:858] running auto-tune for Backward-Data
MIOpen(HIP): Warning [FindRecordUnsafe] File is unreadable: /opt/rocm/miopen/share/miopen/db/gfx900_56.cd.pdb.txt
2018-04-16 00:43:41.130803: I tensorflow/core/kernels/conv_grad_input_ops.cc:858] running auto-tune for Backward-Data
MIOpen(HIP): Warning [FindRecordUnsafe] File is unreadable: /opt/rocm/miopen/share/miopen/db/gfx900_56.cd.pdb.txt
2018-04-16 00:43:41.191681: I tensorflow/core/kernels/conv_ops.cc:670] running auto-tune for Convolve
MIOpen(HIP): Warning [FindRecordUnsafe] File is unreadable: /opt/rocm/miopen/share/miopen/db/gfx900_56.cd.pdb.txt
“Style transfer” is also made by a combination of common CNN technology, so it seems that ROCm - TensorFlow also works well.
source
wreck
wave
udnie
scream
rain_princess
la_muse
Picture-based neural networks are very fun for me!
References
- ROCm-TensorFlow https://github.com/ROCmSoftwarePlatform/tensorflow
- ROCm https://github.com/RadeonOpenCompute/ROCm
- MIOpen https://gpuopen.com/compute-product/miopen/
- GPUEater https://www.gpueater.com/help#hiptensorflow
- OpenCV https://github.com/opencv
- lengstrom repos https://github.com/lengstrom/fast-style-transfer
- Controlling Perceptual Factors in Neural Style Transfer https://arxiv.org/pdf/1611.07865.pdf
Are you interested in working with us?
We are actively looking for new members for developing and improving GPUEater cloud platform. For more information, please check here.
GPU EATER - AMD GPU-based Deep Learning Cloud
- Cloud
- GPU
- OpenCL
- MIOpen
- AMD
- ROCm
- DeepLearning
- Style Transfer
- TensorFlow
- HIP-TensorFlow
- DCGAN
- DeepDream
- Image Recognition