Computer Science/Artificial Intelligence
tensorflow-custom-op (1/2)
BaeMinCheon
2019. 7. 7. 14:27
tensorflow-custom-op
- this post covers
- set up the environment for developing custom op using TF-cpu
- build custom op using TF-cpu into package
- extract the package
- next post covers
- set up the environment for developing custom op using TF-gpu
- build custom op using TF-gpu into package
- environment
- Windows / 10 Pro
- Git
- reference
preparation
- sign up for Docker Hub
- install Docker Desktop for Windows from here
- execute the installer and follow default options
- execute the command prompt
- type docker and now you can check out whether the docker command works
- execute Docker Desktop
- check out whether it is in the running state
- type "docker pull tensorflow/tensorflow:custom-op" to download docker image
- now you are ready to create container
- type "docker run -it tensorflow/tensorflow:custom-op /bin/bash"
- this will create container and enter to it with bash
build-package
- clone the "custom-op" repository in proper directory
- I cloned it in the home directory with "cd ~"
- and change directory into the cloned folder
- type "./configure.sh"
- in this post, we gotta learn about custom op with cpu
- type "bazel build build_pip_pkg" and "bazel-bin/build_pip_pkg artifacts"
- this will create python package from default code of cloned repository
install-pacakge
- you can check out the package in "/artifacts"
- this package only can be installed in linux system
- type "pip install [package-name].whl"
- you can check out in the interpreter whether the package is successfully installed
extract-package
- remember path of the pacakge
- in my case, it was "/root/custom-op/artifacts/[package-name].whl"
- execute another command prompt in host, which is Windows
- type "docker cp [src-path] [dst-path]"
- in my case, it was "docker cp 7dbcce24ce68:/root/custom-op/artifacts/tensorflow_zero_out-0.0.1-cp27-cp27mu-linux_x86_64.whl d:/_downloads"
- you can check out the package in file explorer, too