KoSpacing
KoSpacing copied to clipboard
keras의 버전 업그레이드가 실패합니다.
현재 KoSpacing은 파이썬 3.6, h5py 2.10.0, tenserflow 1.9.0 keras 2.1.5 로 버전을 고정해야 합니다. (python 3.6은 tenserflow 1.9.0의 제약사항으로 tf를 올리지 못하면 python 버전을 올릴 수 없습니다.)
reticulate의 python 버전 고정 문제로 새로운 conda env 를 구성하여 진행할 때 아래 에러메세지와 함께 reticulate 1.25 버전에서 conda env를 찾지 못하는 문제가 있습니다. (아마도 windows)
Error in Sys.setenv(PATH = new_path) : wrong length for argument
그래서 기존 r-reticulate 환경을 그대로 사용할 수 있거나, 환경을 찾지 못하는 문제를 우회하기 위해 python 3.8 이상으로 업그레이드를 해야 하는데요.
keras를 2.1.5 버전보다 상위로 올리면 아래와 같은 에러가 발생합니다.
keras <- reticulate::import("keras")
> model <- keras$models$load_model(model_file, compile = FALSE)
2022-07-30 13:48:43.523325: I tensorflow/core/platform/cpu_feature_guard.cc:142] 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.
Error in py_call_impl(callable, dots$args, dots$keywords) :
NotImplementedError: Cannot convert a symbolic Tensor (gru_1/strided_slice:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported
> model <- keras$models$load_model(model_file, compile = TRUE)
Error in py_call_impl(callable, dots$args, dots$keywords) :
NotImplementedError: Cannot convert a symbolic Tensor (gru_1/strided_slice_1:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported
하여, 패키지를 유지하기 위해서는 2가지 방법이 있습니다.
- reticulate 패키지의 문제가 해결되도록 한다.
- 모델을 수정하여 최신 버전의 패키지나 다른 프레임워크를 사용하여 제공한다.
본 레포는 1번의 방식으로 진행하면 좋을 것 같습니다. 아마도 패키지 사용에 관심이 있으신 분이 reticulate 패키지에 문의를 지속하면 좋겠습니다. 같은 에러 메세지가 몇번 있었던거 같습니다만, 쉽지 않아 보입니다. https://github.com/rstudio/reticulate/issues?q=Error+in+Sys.setenv%28PATH+%3D+new_path%29+%3A+wrong+length+for+argument
2번에 해당하는 접근은 제가 개인적으로 해보려고 합니다. 우선은 모델 컨버터를 사용해 다른 프레임워크를 사용하는 시도를 해보겠습니다. 이것도 잘 안되면, 새로 만들어야 할텐데 아직 잘 모르겠네요.
우선 더 이상 문제를 해결하기 힘들다는 점을 다른 분들께도 공유하고 싶어서 이슈 남깁니다. 감사합니다.