Closed tom2698 closed 1 month ago
That example hasn't been tested in a while, sorry! Try pinning the numpy version to less than 1.20 in the pip_install command.
Okay, so I just modified this line in pokemon_naming.py and it worked.
rnn_image = modal.Image.debian_slim().pip_install(
"keras",
"pandas",
"numpy~=1.23.5",
"tensorflow",
)
I've got another issue now though. Is the base URL for the front end set anywhere? It wasn't actually hitting the API so I just modified the API calls to include the .run URL supplied when serving the app and it actually hit the API and it generated the cards but it wasn't updating the front end, it just stayed loading.
Turns out there was a CORS issue due to me hosting the front end locally and trying to reach the modal API. So I modified the vite.config.js in front to look like this ( maybe should grab the target URL from an ENV variable and set that up before running the front end? )
import { defineConfig, loadEnv } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const venv = loadEnv(mode, process.cwd(), "");
const env = Object.keys(venv)
.filter((item) => item.startsWith("VITE_"))
.reduce((cur, key) => {
return Object.assign(cur, { [key]: venv[key] });
}, {});
const htmlPlugin = () => {
return {
name: "html-transform",
transformIndexHtml(html) {
return html.replace(/%(.*?)%/g, function (match, p1) {
return env[p1];
});
},
};
};
return {
plugins: [svelte(), htmlPlugin()],
server: {
watch: {
usePolling: true,
},
proxy: {
'/api': {
target: '.run link ( I just removed mine)',
changeOrigin: true,
}
}
},
};
});
This allowed it to hit the modal URL and work. Should I create a PR for these changes?
Thanks for reporting! I think it's actually not intended that you host the frontend locally -- instead, I believe it's intended that you use modal serve
and develop with a frontend served via FastAPI on Modal. cc @thundergolfer
I'm testing out the text to pokemon example. I've started up the main file and I get this error. Am I missing something?
2024-08-01 04:21:48.454367: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable
TF_ENABLE_ONEDNN_OPTS=0
. 2024-08-01 04:21:48.457969: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used. 2024-08-01 04:21:48.517083: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used. 2024-08-01 04:21:48.538584: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:485] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered 2024-08-01 04:21:48.580613: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:8454] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered 2024-08-01 04:21:48.586829: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1452] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered 2024-08-01 04:21:48.620489: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2024-08-01 04:21:50.031692: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT Total chars: 28 Corpus length: 8218 Number of names: 958 Longest name: 12 Number of sequences: 8206 First 10 sequences and next chars: X=[bulbasaur iv] y=[y] X=[ulbasaur ivy] y=[s] X=[lbasaur ivys] y=[a] X=[basaur ivysa] y=[u] X=[asaur ivysau] y=[r] X=[saur ivysaur] y=[ ] X=[aur ivysaur ] y=[v] X=[ur ivysaur v] y=[e] X=[r ivysaur ve] y=[n] X=[ ivysaur ven] y=[u] /root/text_to_pokemon/pokemon_naming.py:179: FutureWarning: In the futurenp.bool
will be defined as the corresponding NumPy scalar. X = np.zeros((num_sequences, max_sequence_len, num_chars), dtype=np.bool) Traceback (most recent call last): File "/pkg/modal/_container_io_manager.py", line 508, in handle_input_exception yield File "/pkg/modal/_container_entrypoint.py", line 383, in run_input_sync res = finalized_function.callable(*local_input.args, **local_input.kwargs) File "/root/text_to_pokemon/ops.py", line 115, in generate_pokemon_names model = train_rnn( File "/root/text_to_pokemon/pokemon_naming.py", line 209, in train_rnn dataset = prep_dataset(training_names, max_sequence_len) File "/root/text_to_pokemon/pokemon_naming.py", line 179, in prep_dataset X = np.zeros((num_sequences, max_sequence_len, num_chars), dtype=np.bool) File "/usr/local/lib/python3.10/site-packages/numpy/init.py", line 313, in getattr raise AttributeError(__former_attrs_[attr]) AttributeError: module 'numpy' has no attribute 'bool'.np.bool
was a deprecated alias for the builtinbool
. To avoid this error in existing code, usebool
by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool` here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations