Practical_RL icon indicating copy to clipboard operation
Practical_RL copied to clipboard

Support kaggle notebooks in homework and seminar jupyter notebooks

Open infamax opened this issue 6 months ago • 1 comments

I suggest to add in the beginning part of each jupyter notebooks string to check is kaggle notebooks.

Now check only colab

import sys, os
if 'google.colab' in sys.modules and not os.path.exists('.setup_complete'):
    !wget -q https://raw.githubusercontent.com/yandexdataschool/Practical_RL/master/setup_colab.sh -O- | bash

    !pip install -q gymnasium

    !touch .setup_complete

# This code creates a virtual display to draw game images on.
# It will have no effect if your machine has a monitor.
if type(os.environ.get("DISPLAY")) is not str or len(os.environ.get("DISPLAY")) == 0:
    !bash ../xvfb start
    os.environ['DISPLAY'] = ':1'

It can make be replace by this

import sys, os
if ('google.colab' in sys.modules or os.getenv(KAGGLE_KERNEL_RUN_TYPE)) and not os.path.exists('.setup_complete'):
    !wget -q https://raw.githubusercontent.com/yandexdataschool/Practical_RL/master/setup_colab.sh -O- | bash

    !pip install -q gymnasium

    !touch .setup_complete

# This code creates a virtual display to draw game images on.
# It will have no effect if your machine has a monitor.
if type(os.environ.get("DISPLAY")) is not str or len(os.environ.get("DISPLAY")) == 0:
    !bash ../xvfb start
    os.environ['DISPLAY'] = ':1'

Reason for these changes: kaggle notebook gives gpu for 30 hours straight for a week, which is more convenient for debugging experiments.

infamax avatar Jun 13 '25 12:06 infamax

Sounds good. Could you send a PR?

dniku avatar Jul 06 '25 14:07 dniku