no image
[TensorRT] Windows + TensorRT 설치하기
Windows 환경에서 TensorRT를 설치 하여 Visual Studio 에서 사용 할 수 있다. C++ 지원 Python 미지원 (2020.06.04 TensorRT 7.1 기준) The Windows zip package for TensorRT does not provide Python support. Python may be supported in the future. 설치 환경 windows 10 64bit CUDA 10.0 cuDNN 7.5.0 TensorRT 5.1.5.0 Visual Studio 2015 1. 설치 TensorRT 공식 홈페이지에서 zip 파일로 TensorRT를 다운 받은 뒤 ( Windows를 지원하는 버전이여야함 ) 2. 환경 변수 설정 압축을 풀고, lib 폴더의 ..
2019.11.11
no image
[TensorFlow] TensorFlow 소스 빌드 (Ubuntu 16.04 + GPU + CUDA 10.0 + python + cuDNN 7.3.1)
Python 공식 홈페이지에서 제공하는 우분투 환경에서 파이썬을 사용하기 위해 CUDA 10.0 버전을 기반으로 TensorFlow 를 소스빌드 하는 과정에 대한 포스팅이다. 참고로 윈도우 환경에서 소스빌드 하고 싶다면 아래 링크 참고 https://www.pytorials.com/install-tensorflow-gpu-windows/ 참고로 공식적으로 빌드된 pip 패키지를 통해서 다운 받고 싶다면 아래 명령어 실행 $ pip install tensorflow TensorFlow 를 직접 소스 빌드하는 방법은 아래와 같다. 구성환경 TensorFlow 1.12 GPU version CUDA 10.0 cuDNN 7.3.1 Computer Capability > 3.0 64 bit Python (32 b..
2019.10.18
[TensorRT] Yolo v3 to onnx
tensorrt/samples/python/yolov3_onnx/yolov3_to_onnx.py 파일을 사용하여 yolo v3 가중치 및 모델을 onnx 모델로 변환 이 코드는 python2 에서만 구동 가능함 $ python yolov3_to_onnx.py Layer of type yolo not supported, skipping ONNX node generation. Layer of type yolo not supported, skipping ONNX node generation. Layer of type yolo not supported, skipping ONNX node generation. graph YOLOv3-608 ( %000_net[FLOAT, 64x3x608x608] ) initial..
2019.10.08
[TensorRT] support matrix 지원 가능한 레이어 목록
https://docs.nvidia.com/deeplearning/sdk/tensorrt-support-matrix/index.html#layers-precision-matrix TensorRT Support Matrix :: Deep Learning SDK Documentation These support matrices provide a look into the supported platforms, features, and hardware capabilities of the TensorRT 6.0.1 APIs, parsers, and layers. For previously released TensorRT documentation, see TensorRT Archives. docs.nvidia.com..
2019.09.26
[TensorRT] Cuda Error in allocate: 2
[TensorRT] ERROR: runtime.cpp (24) - Cuda Error in allocate: 2 [TensorRT] ERROR: runtime.cpp (24) - Cuda Error in allocate: 2 Cuda Memory 설정과 관련된 문제로서 builder.max_workspace_size = 1
2019.09.19
[TensorRT] keras model 에서 node name 확인하는 방법
아래와 같은 에러 발생 시 [TensorRT] ERROR: Parameter check failed at: ../builder/Network.cpp::addInput::406, condition: isValidDims(dims) [TensorRT] ERROR: UFFParser: Failed to parseInput for node input_1 [TensorRT] ERROR: UFFParser: Parser error: input_1: Failed to parse node - Invalid Tensor found at node input_1 input shape을 (224, 224, 3) 가 아닌 [224, 224, 3] 으로 넣어주어야 함 그리고 keras model의 input node name, ..
2019.09.19
[CUDA] PyCUDA documentation
간단한 예제 import pycuda.autoinit import pycuda.driver as drv import numpy from pycuda.compiler import SourceModule mod = SourceModule(""" __global__ void multiply_them(float *dest, float *a, float *b) { const int i = threadIdx.x; dest[i] = a[i] * b[i]; } """) multiply_them = mod.get_function("multiply_them") a = numpy.random.randn(400).astype(numpy.float32) b = numpy.random.randn(400).astype(numpy...
2019.08.04
[TensorFlow] Graph 에서 dropout 을 제거하는 방법
흔히들 드롭 아웃을 적용하여 네트워크를 설계하는데 다른 플랫폼에서 고정된 그래프를 사용하고자 할 때 다음과 같은 오류가 발생한다고 한다. Invalid argument: No OpKernel was registered to support Op 'RandomUniform' with these attrs. Registered devices: [CPU], Registered kernels: [[Node: dropout/random_uniform/RandomUniform = RandomUniform[T=DT_INT32, dtype=DT_FLOAT, seed=0, seed2=0](dropout/Shape)]] 이 때 만들어진 pb 파일을 이용하여 드롭 아웃을 제거하는 과정을 거친다. How to remove dr..
2019.08.03
no image
[TensorRT] 마지막 노드 찾기
이 포스팅은 Tensorflow 에서 이미 만들어진 ckpt 파일을 가지고 TensorRT로 변환하는 과정에서 마지막 노드를 찾기 위하여 겪게 된 삽질들을 적어두었다 ^^ Tensorflow에서 이미 만들어진 ckpt 파일만 가지고 pb 파일을 생성할 수 없기 때문에, ckpt 파일을 가지고 모델을 테스트 하는 과정에서 iteration 한번으로 pbtxt 를 생성하였다. 이 때 중요한 점은 테스트를 한번 돌려서 pb 파일을 생성할 수도 있지만 테스트의 pb와 트레이닝을 끝으로 만들어지는 pb 는 다르다는 것이다. 당연히 내부에 포함되어있는 가중치의 값이 다르니까. pbtxt 는 모델의 구조를 담은 파일인데 이와 ckpt 파일을 가지고 freeze 하여 pb 파일을 얻었다. 이 때 모델의 마지막 노드를 ..
2019.08.03
[TensorFlow] .ckpt vs .pb vs .pbtxt 차이점
간단하게 말하자면 아래와 같다. ckpt 파일 모델의 변수(가중치)인 체크포인트 파일 pb 파일 모델의 변수 + 구조 (즉, 전체 그래프) 로 이루어진 바이너리 파일 pbtxt 파일 pb 파일을 읽을 수 있는 텍스트 파일, 즉 모델 구조 파악 가능 더욱 자세히 말하자면 아래와 같다 ... ckpt 파일 텐서플로우에서 학습된 모델의 구조를 제외한 변수들을 담고 있는 파일이다. 즉, 모델의 가중치만 담고있는 파일이다. 그래서 모델에 대한 메타정보를 담고있기 때문에 재학습이 가능하다는 특징이 있다. 하지만, 실제 모델을 돌릴 때 필요 없는 정보들이 너무 많아서 파일의 크기가 무겁다는 단점이 있다. 체크포인트의 저장은 다음과 같이 이루어지며, iteration 별로 체크포인트 파일을 생성 할 수 있다. #/mo..
2019.08.03
no image
[TensorRT] TF-TRT vs TRT
TensorFlow에 내장되어있는 TensorRT, 일명 TF-TRT 와 그냥 TensorRT 즉 TRT 와의 성능 차이를 비교하는 벤치마크는 현재 시점(2019.08.03)에 나와있지 않다고 한다. 엔비디아에서 TRT vs TFTRT 에 대한 비교 자료를 만들고 있다고 한다. 참고자료 https://devtalk.nvidia.com/default/topic/1044901/tensorrt/performance-using-the-integration-tensorflow-tensorrt-vs-direct-tensorrt/ https://devtalk.nvidia.com/default/topic/1044901/tensorrt/performance-using-the-integration-tensorflow-te..
2019.08.03
[TensorFlow] 함수 내부에서 TensorFlow Graph 실행하기
텐서플로우 내부에서 코드를 예쁘게 구조화 하여 그래프(Graph)를 실행할 수 있다. 구현할 때, 몇가지 방법이 있다. 1. Tensor 이름 전달하기 with tf.Session(graph=graph) as sess: feed = {"Placeholder:0": 3} print(sess.run("Add:0", feed_dict=feed)) 위와 같이 Placeholder:0 이라는 텐서 자체를 feed 에 넘겨주는 것 대신, def build_graph(): g = tf.Graph() with g.as_default(): a = tf.placeholder(tf.int8, name="a") b = tf.add(a, tf.constant(1, dtype=tf.int8), name="b") return g ..
2019.08.03