TX2 install mxnet for cpp with cuda support [build from source]


龜龜是最可愛的小貓咪

環(huán)境:cuda9.0&cudnn7.0.5

Install mxnet for cpp package in TX2 is not that easy

Record here for my experience.

Steps:

Follow the documentation on this site Install MXNet on a Jetson , there is a little different

  1. First clone mxnet from github && cd mxnet

    git clone --recursive https://github.com/apache/incubator-mxnet.git mxnet
    cd mxnet
    git submodule init
    git submodule update
    
  2. Configure CUDA:

    nvcc --version
    

    on my TX2 is CUDA9.0

    sudo rm /usr/local/cuda
    sudo ln -s /usr/local/cuda-9.0 /usr/local/cuda
    
  3. Copy config.mk

      cp make/crosscompile.jetson.mk config.mk
    
  4. Edit config.mk, in config.mk , modify these settings:

    1. USE_CUDA_PATH = /usr/local/cuda

    2. USE_OPENCV = 1

    3. USE_JEMALLOC = 0 which is different from official guide but VERY IMPORTENT

    4. USE_GPERFTOOLS = 0 which is different from official guide but **VERY IMPORTENT

    5. USE_CPP_PACKAGE = 1 for cpp package

    6. Update the NVCC settings. NVCCFLAGS := -m64

    there 3 and 4 is important , or when you finish your build , using the mxnet api , you might get error like :

    src/tcmalloc.cc:284] Attempt to free invalid pointer
    
  5. in 3rdparty/mshadow/make/mshadow.mk, change this setteing as follow:

    MSHADOW_CFLAGS += -DMSHADOW_USE_PASCAL=1
    
  6. Something else:

    in Makefile, limit the arch for tx2, which is important.
    KNOWN_CUDA_ARCHS := 62 # limit arch for tx2 here

    ifeq ($(USE_CUDA), 1)
    ifeq ($(CUDA_ARCH),)
     # KNOWN_CUDA_ARCHS := 30 35 50 52 60 61 70 75
     KNOWN_CUDA_ARCHS := 62    # limit arch for tx2 here
     # Run nvcc on a zero-length file to check architecture-level support.
     # Create args to include SASS in the fat binary for supported levels.
     CUDA_ARCH := $(foreach arch,$(KNOWN_CUDA_ARCHS), \
                 $(shell $(NVCC) -arch=sm_$(arch) -E --x cu /dev/null >/dev/null 2>&1 && \
                         echo -gencode arch=compute_$(arch),code=sm_$(arch)))
     # Convert a trailing "code=sm_NN" to "code=[sm_NN,compute_NN]" to also
     # include the PTX of the most recent arch in the fat-binaries for
     # forward compatibility with newer GPUs.
     CUDA_ARCH := $(shell echo $(CUDA_ARCH) | sed 's/sm_\([0-9]*\)$$/[sm_\1,compute_\1]/')
     # Add fat binary compression if supported by nvcc.
     COMPRESS := --fatbin-options -compress-all
     CUDA_ARCH += $(shell $(NVCC) -cuda $(COMPRESS) --x cu /dev/null -o /dev/null >/dev/null 2>&1 && \
                          echo $(COMPRESS))
    endif
    $(info Running CUDA_ARCH: $(CUDA_ARCH))
    endif
    

OR you might get error like :

INFO: nvcc was not found on your path
INFO: Using /usr/local/cuda-9.0/bin/nvcc as nvcc path
Running CUDA_ARCH: -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=[sm_70,compute_70] --fatbin-options -compress-all

...

DMXNET_USE_LIBJPEG_TURBO=0" src/operator/tensor/broadcast_reduce_op_value.cu
Killed
Makefile:471: recipe for target 'build/src/operator/tensor/ordering_op_gpu.o' failed
make: *** [build/src/operator/tensor/ordering_op_gpu.o] Error 137
make: *** Waiting for unfinished jobs....
  1. when you finished your built and use its cpp api, you may meet error like this:

    terminate called after throwing an instance of 'dmlc::Error'
    what(): [01:20:54] /usr/include/mxnet-cpp/ndarray.hpp:236: Check failed: MXNDArrayWaitToRead(blob_ptr_->handle_) == 0 (-1 vs. 0)

  terminate called after throwing an instance of 'dmlc::Error'
      what(): [01:20:54] /usr/include/mxnet-cpp/ndarray.hpp:236: Check failed: MXNDArrayWaitToRead(blob_ptr_->handle_) == 0 (-1 vs. 0)
  this is a problem on gpu mode, which is resulted of TX2 **out of memory**, change the input to a smaller one can solve.
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末茫打,一起剝皮案震驚了整個(gè)濱河市浴栽,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌楚午,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,183評(píng)論 6 516
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件奈辰,死亡現(xiàn)場離奇詭異丈屹,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)判族,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,850評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門躺盛,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人形帮,你說我怎么就攤上這事槽惫。” “怎么了辩撑?”我有些...
    開封第一講書人閱讀 168,766評(píng)論 0 361
  • 文/不壞的土叔 我叫張陵界斜,是天一觀的道長。 經(jīng)常有香客問我合冀,道長各薇,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,854評(píng)論 1 299
  • 正文 為了忘掉前任君躺,我火速辦了婚禮峭判,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘棕叫。我一直安慰自己林螃,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,871評(píng)論 6 398
  • 文/花漫 我一把揭開白布俺泣。 她就那樣靜靜地躺著治宣,像睡著了一般急侥。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上侮邀,一...
    開封第一講書人閱讀 52,457評(píng)論 1 311
  • 那天坏怪,我揣著相機(jī)與錄音,去河邊找鬼绊茧。 笑死铝宵,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的华畏。 我是一名探鬼主播鹏秋,決...
    沈念sama閱讀 40,999評(píng)論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼亡笑!你這毒婦竟也來了侣夷?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,914評(píng)論 0 277
  • 序言:老撾萬榮一對(duì)情侶失蹤仑乌,失蹤者是張志新(化名)和其女友劉穎百拓,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體晰甚,經(jīng)...
    沈念sama閱讀 46,465評(píng)論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡衙传,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,543評(píng)論 3 342
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了厕九。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片蓖捶。...
    茶點(diǎn)故事閱讀 40,675評(píng)論 1 353
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖扁远,靈堂內(nèi)的尸體忽然破棺而出俊鱼,到底是詐尸還是另有隱情,我是刑警寧澤畅买,帶...
    沈念sama閱讀 36,354評(píng)論 5 351
  • 正文 年R本政府宣布并闲,位于F島的核電站,受9級(jí)特大地震影響皮获,放射性物質(zhì)發(fā)生泄漏焙蚓。R本人自食惡果不足惜纹冤,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,029評(píng)論 3 335
  • 文/蒙蒙 一洒宝、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧萌京,春花似錦雁歌、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,514評(píng)論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春乏盐,著一層夾襖步出監(jiān)牢的瞬間佳窑,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,616評(píng)論 1 274
  • 我被黑心中介騙來泰國打工父能, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留神凑,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 49,091評(píng)論 3 378
  • 正文 我出身青樓何吝,卻偏偏與公主長得像溉委,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子爱榕,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,685評(píng)論 2 360

推薦閱讀更多精彩內(nèi)容