美文网首页深度学习Ubuntu
Nvidia Jetson nano 研究系列之四-配置pyth

Nvidia Jetson nano 研究系列之四-配置pyth

作者: 大道至简非简 | 来源:发表于2019-05-02 11:52 被阅读106次

    1、pip3方式安装tensorflow-gpu

    官方文件地址为:
    https://developer.nvidia.com/embedded/downloads#?search=TensorFlow

    image.png
    url为:https://developer.download.nvidia.com/compute/redist/jp/v42/tensorflow-gpu/tensorflow_gpu-1.13.1+nv19.4-cp36-cp36m-linux_aarch64.whl

    安装基础必备的包

    sudo apt-get install python3-numpy   #不知道numpy是干啥的?机器学习这个领域不适合你
    sudo apt-get install python3-scipy
    sudo apt-get install python3-pandas
    sudo apt-get install python3-matplotlib
    sudo apt-get install python3-sklearn
    sudo apt-get install libhdf5-serial-dev hdf5-tools
    
    

    安装脚本

    pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu==1.13.1+nv19.4 --user
    

    执行如下:(需要下载的依赖组件比较多,时间较长)

    root@jetson-desktop:~# pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu==1.13.1+nv19.4 --user
    Looking in indexes: https://pypi.org/simple, https://developer.download.nvidia.com/compute/redist/jp/v42
    Collecting tensorflow-gpu==1.13.1+nv19.4
      Downloading https://developer.download.nvidia.cn/compute/redist/jp/v42/tensorflow-gpu/tensorflow_gpu-1.13.1%2Bnv19.4-cp36-cp36m-linux_aarch64.whl (204.6MB)
         |████████████████████████████████| 204.6MB 127kB/s 
    Requirement already satisfied: six>=1.10.0 in /usr/lib/python3/dist-packages (from tensorflow-gpu==1.13.1+nv19.4) (1.11.0)
    Collecting termcolor>=1.1.0 (from tensorflow-gpu==1.13.1+nv19.4)
      Downloading https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
    
    
    Successfully installed absl-py-0.7.1 astor-0.7.1 gast-0.2.2 grpcio-1.20.1 h5py-2.9.0 keras-applications-1.0.7 keras-preprocessing-1.0.9 markdown-3.1 mock-2.0.0 pbr-5.2.0 protobuf-3.7.1 tensorboard-1.13.1 tensorflow-estimator-1.13.0 tensorflow-gpu-1.13.1+nv19.4 werkzeug-0.15.2
    
    
    

    2、测试tensorflow-gpu

    简单demo看能否跑的起来

    import tensorflow as tf
    hello = tf.constant('Hello, TensorFlow!')
    sess = tf.Session()
    print(sess.run(hello))
    
    
    

    出现numpy错误

    >>> import tensorflow as tf
    RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
    ImportError: numpy.core.multiarray failed to import
    ImportError: numpy.core.umath failed to import
    ImportError: numpy.core.umath failed to import
    2019-05-02 10:29:02.103748: F tensorflow/python/lib/core/bfloat16.cc:675] Check failed: PyBfloat16_Type.tp_base != nullptr 
    Aborted (core dumped)
    

    解决方法如下,numpy版本不匹配;
    https://github.com/enigmampc/catalyst/issues/106

    pip3 install -U numpy==1.14.1
    
    

    运行效果

    root@jetson-desktop:~# python3
    Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
    [GCC 8.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import tensorflow as tf
    >>> hello = tf.constant('Hello, TensorFlow!')
    >>> sess = tf.Session()
    2019-05-02 10:46:43.015448: W tensorflow/core/platform/profile_utils/cpu_utils.cc:98] Failed to find bogomips in /proc/cpuinfo; cannot determine CPU frequency
    2019-05-02 10:46:43.016104: I tensorflow/compiler/xla/service/service.cc:161] XLA service 0x1307c2a0 executing computations on platform Host. Devices:
    2019-05-02 10:46:43.016166: I tensorflow/compiler/xla/service/service.cc:168]   StreamExecutor device (0): <undefined>, <undefined>
    2019-05-02 10:46:43.276331: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:965] ARM64 does not support NUMA - returning NUMA node zero
    2019-05-02 10:46:43.276628: I tensorflow/compiler/xla/service/service.cc:161] XLA service 0x119a25d0 executing computations on platform CUDA. Devices:
    2019-05-02 10:46:43.276686: I tensorflow/compiler/xla/service/service.cc:168]   StreamExecutor device (0): NVIDIA Tegra X1, Compute Capability 5.3
    2019-05-02 10:46:43.277941: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties: 
    name: NVIDIA Tegra X1 major: 5 minor: 3 memoryClockRate(GHz): 0.9216
    pciBusID: 0000:00:00.0
    totalMemory: 3.87GiB freeMemory: 939.80MiB
    2019-05-02 10:46:43.278022: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0
    2019-05-02 10:46:44.444240: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:
    2019-05-02 10:46:44.444318: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990]      0 
    2019-05-02 10:46:44.444348: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0:   N 
    2019-05-02 10:46:44.444540: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 400 MB memory) -> physical GPU (device: 0, name: NVIDIA Tegra X1, pci bus id: 0000:00:00.0, compute capability: 5.3)
    >>> print(sess.run(hello))
    b'Hello, TensorFlow!'
    

    tensorflow-gpu正常启用。

    相关文章

      网友评论

        本文标题:Nvidia Jetson nano 研究系列之四-配置pyth

        本文链接:https://www.haomeiwen.com/subject/raagnqtx.html