반응형

tensorflow 소스 실행시 아래와 같은 에러가 발생하면

Exception: URL fetch failure on https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz: None -- [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)

OSX 환경이라면 아래 커맨드를 실행해주자.
!!!중요  Python 버전은 자신의 환경에 맞게 고쳐서 실행하자 !!!

/Applications/Python\ 3.7/Install\ Certificates.command

 

아니면 해당 소스코드에 아래 내용을 넣어줘도 된다.

import requests
requests.packages.urllib3.disable_warnings()
import ssl
try:
    _create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
    # Legacy Python that doesn't verify HTTPS certificates by default
    pass
else:
    # Handle target environment that doesn't support HTTPS verification
    ssl._create_default_https_context = _create_unverified_https_context

 

아니면 아래 링크를 참고해서 문제를 해결 하도록 하자.

https://stackoverflow.com/questions/58012741/error-importing-tensorflow-alreadyexistserror-another-metric-with-the-same-nam

반응형

tensorflow v2 에서 v1 버전 소스코드를 실행하면 에러가 발생한다.

AttributeError: module 'tensorflow' has no attribute 'Session'

tensorflow v1에서 작성된 코드를 v2환경에서 실행했을때 발생하는 경우인데

import tensorflow as tf

아래 처럼 변경 및 추가를 해주면 실행 가능

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
반응형

tensorflow를 활용한 python 코드 실행시 아래와 같은 메세지가 나온다면

This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations:  AVX AVX2 
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.

 

실행 소스 상단에 아래 소스 두줄만 넣어 주면 된다.
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

Tensorflow는 TF_CPP_MIN_LOG_LEVEL 이라는 환경변수를 통해 로깅을 제어 할 수 있으므로 설정을 통해 해결 가능하다.

기본값은 0(모든 로그 표시) , 1(INFO 로그 필터링), 2(WARNING 로그 필터), 3(ERROR 로그 필터)

 
import os
import tensorflow as tf
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
hellow = tf.constant('hellow' )
print(hellow)

+ Recent posts