카테고리 없음

Jetson nano tensorflow 설치

nalabi 2020. 3. 1. 19:11

의존성 때문에 모듈을 미리 설치 합니다.

sudo apt-get install python3-setuptools
sudo apt-get install libhdf5-dev
sudo apt install python3-pip -y
sudo pip3 install -U pip
sudo pip3 install --upgrade cython
sudo pip3 install -U numpy future mock h5py keras_preprocessing keras_applications gast enum34 futures protobuf

 

tensorflow 설치합니다.

1.x 버전과 2.x버전이 많이 다릅니다.

 

https://developer.download.nvidia.com/compute/redist/jp/

 

sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu

메모리 부족현상( Out of memory) 임시 해결방안

python 코드에 추가합니다.

#------------------------------------------------
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
  # Restrict TensorFlow to only allocate 1GB of memory on the first GPU
  try:
    tf.config.experimental.set_virtual_device_configuration(
        gpus[0],
        [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=1024)])
    logical_gpus = tf.config.experimental.list_logical_devices('GPU')
    print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs")
  except RuntimeError as e:
    # Virtual devices must be set before GPUs have been initialized
    print(e)
#------------------------------------------------

 

--gpu 옵션을 .8로 합니다.

flow --model cfg/yolov2.cfg --load yolov2.weights --demo ../video/sin.avi --gpu .8 --saveVideo

 

이런류의 오류 메시가 나오면

AssertionError: expect 268406952 bytes, found 268406956

 

vi /home/kyi/.local/lib/python3.6/site-packages/darkflow/utils/loader.py

class weights_walker(object):
    """incremental reader of float32 binary files"""
    def __init__(self, path):
        self.eof = False # end of file
        self.path = path  # current pos
        if path is None:
            self.eof = True
            return
        else:
            self.size = os.path.getsize(path)# save the path
            major, minor, revision, seen = np.memmap(path,
                shape = (), mode = 'r', offset = 0,
                dtype = '({})i4,'.format(4))
            self.transpose = major > 1000 or minor > 1000
            self.offset = 16 + 268406956-268406952

            self.offset = 16 + 268406956-268406952 이걸 추가 한다.