Caffe2 - Python API
A deep learning, cross platform ML framework
__init__.py
1 from __future__ import absolute_import, division, print_function, unicode_literals
2 from caffe2.proto import caffe2_pb2
3 import os
4 import sys
5 import platform
6 # TODO: refactor & remove the following alias
7 caffe2_pb2.CPU = caffe2_pb2.PROTO_CPU
8 caffe2_pb2.CUDA = caffe2_pb2.PROTO_CUDA
9 caffe2_pb2.MKLDNN = caffe2_pb2.PROTO_MKLDNN
10 caffe2_pb2.OPENGL = caffe2_pb2.PROTO_OPENGL
11 caffe2_pb2.OPENCL = caffe2_pb2.PROTO_OPENCL
12 caffe2_pb2.IDEEP = caffe2_pb2.PROTO_IDEEP
13 caffe2_pb2.HIP = caffe2_pb2.PROTO_HIP
14 caffe2_pb2.COMPILE_TIME_MAX_DEVICE_TYPES = caffe2_pb2.PROTO_COMPILE_TIME_MAX_DEVICE_TYPES
15 caffe2_pb2.ONLY_FOR_TEST = caffe2_pb2.PROTO_ONLY_FOR_TEST
16 
17 if platform.system() == 'Windows':
18  # first get nvToolsExt PATH
19  def get_nvToolsExt_path():
20  NVTOOLEXT_HOME = os.getenv('NVTOOLSEXT_PATH', 'C:\\Program Files\\NVIDIA Corporation\\NvToolsExt')
21 
22  if os.path.exists(NVTOOLEXT_HOME):
23  return os.path.join(NVTOOLEXT_HOME, 'bin', 'x64')
24  else:
25  return ''
26 
27  py_dll_path = os.path.join(os.path.dirname(sys.executable), 'Library', 'bin')
28  th_root = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'torch')
29  th_dll_path = os.path.join(th_root, 'lib')
30 
31  dll_paths = [th_dll_path, py_dll_path, get_nvToolsExt_path(), os.environ['PATH']]
32 
33  # then add the path to env
34  os.environ['PATH'] = ';'.join(dll_paths)