| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,6 +55,10 @@ ADD clean-layer.sh /tmp/clean-layer.sh | |||
| 55 | 55 | ADD patches/nbconvert-extensions.tpl /opt/kaggle/nbconvert-extensions.tpl | |
| 56 | 56 | ADD patches/template_conf.json /opt/kaggle/conf.json | |
| 57 | 57 | ||
| 58 | + # b/276344496: Install specific version of boto3, because 1.26.103 is broken. | ||
| 59 | + RUN pip install boto3==1.26.100 && \ | ||
| 60 | + /tmp/clean-layer.sh | ||
| 61 | + | ||
| 58 | 62 | {{ if eq .Accelerator "gpu" }} | |
| 59 | 63 | # b/200968891 Keeps horovod once torch is upgraded. | |
| 60 | 64 | RUN pip uninstall -y horovod && \ | |
@@ -423,6 +427,7 @@ RUN pip install annoy \ | |||
| 423 | 427 | /tmp/clean-layer.sh | |
| 424 | 428 | ||
| 425 | 429 | # b/273059949 The pre-installed nbconvert is slow on html conversions and has to be force-uninstalled. | |
| 430 | + # b/274619697 learntools also requires a specific nbconvert right now | ||
| 426 | 431 | RUN rm -rf /opt/conda/lib/python3.7/site-packages/nbconvert* | |
| 427 | 432 | RUN rm -rf /opt/conda/lib/python3.7/site-packages/mistune* | |
| 428 | 433 | ||
@@ -449,12 +454,11 @@ RUN pip install bleach \ | |||
| 449 | 454 | mistune \ | |
| 450 | 455 | nbformat \ | |
| 451 | 456 | notebook \ | |
| 452 | - "nbconvert<7" \ | ||
| 457 | + "nbconvert==6.4.5" \ | ||
| 453 | 458 | papermill \ | |
| 454 | 459 | python-lsp-server[all] \ | |
| 455 | 460 | olefile \ | |
| 456 | - # b/198300835 kornia 0.5.10 is not compatible with our version of numpy. | ||
| 457 | - kornia==0.5.8 \ | ||
| 461 | + kornia \ | ||
| 458 | 462 | pandas_summary \ | |
| 459 | 463 | pandocfilters \ | |
| 460 | 464 | pexpect \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,12 @@ | |||
| 1 | 1 | import os | |
| 2 | + import sys | ||
| 3 | + from os import listdir | ||
| 4 | + from os.path import isdir, join | ||
| 2 | 5 | from kaggle_web_client import KaggleWebClient | |
| 3 | 6 | ||
| 4 | 7 | _KAGGLE_TPU_NAME_ENV_VAR_NAME = 'TPU_NAME' | |
| 8 | + _KAGGLE_TPUVM_NAME_ENV_VAR_NAME = 'ISTPUVM' | ||
| 9 | + _KAGGLE_INPUT_DIR = '/kaggle/input' | ||
| 5 | 10 | ||
| 6 | 11 | class KaggleDatasets: | |
| 7 | 12 | GET_GCS_PATH_ENDPOINT = '/requests/CopyDatasetVersionToKnownGcsBucketRequest' | |
@@ -14,8 +19,20 @@ class KaggleDatasets: | |||
| 14 | 19 | def __init__(self): | |
| 15 | 20 | self.web_client = KaggleWebClient() | |
| 16 | 21 | self.has_tpu = os.getenv(_KAGGLE_TPU_NAME_ENV_VAR_NAME) is not None | |
| 22 | + self.has_tpuvm = os.getenv(_KAGGLE_TPUVM_NAME_ENV_VAR_NAME) is not None | ||
| 17 | 23 | ||
| 18 | 24 | def get_gcs_path(self, dataset_dir: str = None) -> str: | |
| 25 | + if self.has_tpuvm: | ||
| 26 | + if dataset_dir is None: | ||
| 27 | + onlydirs = [f for f in listdir(_KAGGLE_INPUT_DIR) if isdir(join(_KAGGLE_INPUT_DIR, f))] | ||
| 28 | + if len(onlydirs) == 1: | ||
| 29 | + dataset_dir = onlydirs[0] | ||
| 30 | + else: | ||
| 31 | + raise Exception("Could not infer dataset_dir. dataset_dir can only be inferred if there is exactly 1 Kaggle dataset attached.") | ||
| 32 | + dataset = join(_KAGGLE_INPUT_DIR, dataset_dir) | ||
| 33 | + print("get_gcs_path is not required on TPU VMs which can directly use Kaggle datasets, using path: " + dataset, file=sys.stderr) | ||
| 34 | + return dataset | ||
| 35 | + | ||
| 19 | 36 | integration_type = self.TPU if self.has_tpu else self.AUTO_ML | |
| 20 | 37 | data = { | |
| 21 | 38 | 'MountSlug': dataset_dir, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,13 +7,13 @@ | |||
| 7 | 7 | class TestKornia(unittest.TestCase): | |
| 8 | 8 | def test_imread_opencv(self): | |
| 9 | 9 | img = cv2.imread('/input/tests/data/dot.png') | |
| 10 | - img_t = kornia.image_to_tensor(img) | ||
| 10 | + img_t = kornia.utils.image_to_tensor(img) | ||
| 11 | 11 | ||
| 12 | 12 | self.assertEqual(img.shape, (1, 1, 3)) | |
| 13 | 13 | self.assertEqual(img_t.shape, (3, 1, 1)) | |
| 14 | 14 | ||
| 15 | 15 | def test_grayscale_torch(self): | |
| 16 | 16 | img_rgb = torch.rand(2, 3, 4, 5) | |
| 17 | - img_gray = kornia.rgb_to_grayscale(img_rgb) | ||
| 17 | + img_gray = kornia.color.rgb_to_grayscale(img_rgb) | ||
| 18 | 18 | ||
| 19 | 19 | self.assertEqual(img_gray.shape, (2, 1, 4, 5)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,22 +31,24 @@ ADD patches/kaggle_datasets.py /root/.local/lib/python3.8/site-packages/kaggle_d | |||
| 31 | 31 | # sitecustomize adds significant latency to ipython kernel startup and should only be added if needed | |
| 32 | 32 | # ADD patches/sitecustomize.py /root/.local/lib/python3.8/site-packages/sitecustomize.py | |
| 33 | 33 | ||
| 34 | + # LIBTPU installed here: | ||
| 35 | + ENV PIP_LIBTPU=/usr/local/lib/python3.8/site-packages/libtpu/libtpu.so | ||
| 36 | + ENV PYTORCH_LIBTPU=/lib/torch-libtpu.so | ||
| 37 | + | ||
| 34 | 38 | # Tensorflow wheel: | |
| 35 | 39 | RUN pip install tensorflow_hub https://storage.googleapis.com/cloud-tpu-tpuvm-artifacts/tensorflow/tf-${TENSORFLOW_VERSION}/tensorflow-${TENSORFLOW_VERSION}-cp38-cp38-linux_x86_64.whl | |
| 36 | 40 | RUN curl --output /lib/libtpu.so https://storage.googleapis.com/cloud-tpu-tpuvm-artifacts/libtpu/${TF_LIBTPU_VERSION}/libtpu.so | |
| 37 | 41 | ADD patches/kaggle_module_resolver.py /usr/local/lib/python3.8/site-packages/tensorflow_hub/kaggle_module_resolver.py | |
| 38 | 42 | RUN sed -i '/from tensorflow_hub import uncompressed_module_resolver/a from tensorflow_hub import kaggle_module_resolver' /usr/local/lib/python3.8/site-packages/tensorflow_hub/config.py | |
| 39 | 43 | RUN sed -i '/_install_default_resolvers()/a \ \ registry.resolver.add_implementation(kaggle_module_resolver.KaggleFileResolver())' /usr/local/lib/python3.8/site-packages/tensorflow_hub/config.py | |
| 40 | 44 | ||
| 41 | - # LIBTPU installed here: | ||
| 42 | - ENV PIP_LIBTPU=/usr/local/lib/python3.8/site-packages/libtpu/libtpu.so | ||
| 43 | - ENV PYTORCH_LIBTPU=/lib/torch-libtpu.so | ||
| 44 | - | ||
| 45 | 45 | # Install Pytorch & related packages | |
| 46 | 46 | # https://cloud.google.com/tpu/docs/pytorch-xla-ug-tpu-vm#changing_pytorch_version | |
| 47 | 47 | # The URL doesn't include patch version. i.e. must use 1.11 instead of 1.11.0 | |
| 48 | 48 | # We need to keep the numpy version the same as the installed tf one but compatible with other installs. | |
| 49 | - RUN pip install numpy==1.24.2 torch==${TORCH_VERSION} torch_xla[tpuvm] -f https://storage.googleapis.com/tpu-pytorch/wheels/tpuvm/torch_xla-${TORCH_VERSION%.*}-cp38-cp38-linux_x86_64.whl torchvision==${TORCHVISION_VERSION} torchtext==${TORCHTEXT_VERSION} torchaudio==${TORCHAUDIO_VERSION} | ||
| 49 | + RUN pip install torch==${TORCH_VERSION} torch_xla[tpuvm] -f https://storage.googleapis.com/tpu-pytorch/wheels/tpuvm/torch_xla-${TORCH_VERSION%.*}-cp38-cp38-linux_x86_64.whl torchvision==${TORCHVISION_VERSION} torchtext==${TORCHTEXT_VERSION} torchaudio==${TORCHAUDIO_VERSION} \ | ||
| 50 | + https://storage.googleapis.com/cloud-tpu-tpuvm-artifacts/tensorflow/tf-${TENSORFLOW_VERSION}/tensorflow-${TENSORFLOW_VERSION}-cp38-cp38-linux_x86_64.whl \ | ||
| 51 | + numpy==1.23.5 | ||
| 50 | 52 | ||
| 51 | 53 | RUN cp $PIP_LIBTPU $PYTORCH_LIBTPU | |
| 52 | 54 | ||
@@ -56,13 +58,18 @@ RUN sed -i "s|^\(\(.*\)libtpu.configure_library_path.*\)|\1\n\2os.environ['TPU_L | |||
| 56 | 58 | # Install JAX & related packages | |
| 57 | 59 | # https://cloud.google.com/tpu/docs/jax-quickstart-tpu-vm#install_jax_on_your_cloud_tpu_vm | |
| 58 | 60 | # We need to keep the numpy version the same as the installed tf one but compatible with other installs. | |
| 59 | - RUN pip install numpy==1.24.2 jax[tpu]==${JAX_VERSION} -f https://storage.googleapis.com/jax-releases/libtpu_releases.html trax flax optax elegy git+https://github.com/deepmind/dm-haiku jraph distrax | ||
| 61 | + RUN pip install jax[tpu]==${JAX_VERSION} -f https://storage.googleapis.com/jax-releases/libtpu_releases.html trax flax optax elegy git+https://github.com/deepmind/dm-haiku jraph distrax \ | ||
| 62 | + https://storage.googleapis.com/cloud-tpu-tpuvm-artifacts/tensorflow/tf-${TENSORFLOW_VERSION}/tensorflow-${TENSORFLOW_VERSION}-cp38-cp38-linux_x86_64.whl \ | ||
| 63 | + numpy==1.23.5 | ||
| 60 | 64 | ||
| 61 | 65 | # Packages needed by the Notebook editor: | |
| 62 | 66 | RUN pip install papermill jupyterlab python-lsp-server[all] jupyterlab-lsp | |
| 63 | 67 | ||
| 64 | 68 | # Additional useful packages should be added here: | |
| 65 | - RUN pip install pandas | ||
| 69 | + RUN pip install pandas matplotlib | ||
| 70 | + | ||
| 71 | + # Monkey-patch the default TPU to the local (TPU VM). | ||
| 72 | + RUN sed -i 's/tpu=None,/tpu="local",/' /usr/local/lib/python3.8/site-packages/tensorflow/python/distribute/cluster_resolver/tpu/tpu_cluster_resolver.py | ||
| 66 | 73 | ||
| 67 | 74 | # Set these env vars so that they don't produce errs calling the metadata server to load them: | |
| 68 | 75 | ENV TPU_ACCELERATOR_TYPE=v3-8 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | - TENSORFLOW_VERSION=2.11.0 | ||
| 2 | - TF_LIBTPU_VERSION=1.5.0 | ||
| 1 | + TENSORFLOW_VERSION=2.12.0 | ||
| 2 | + TF_LIBTPU_VERSION=1.6.0 | ||
| 3 | 3 | JAX_VERSION=0.4.6 | |
| 4 | 4 | # Supports nightly | |
| 5 | 5 | TORCH_VERSION=2.0.0 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments