{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## IPython Utilities" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Utilities to help work with ipython/jupyter environment." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To import from [`fastai.utils.ipython`](/utils.ipython.html#utils.ipython) do:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "hide_input": true }, "outputs": [], "source": [ "from fastai.gen_doc.nbdoc import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "hide_input": false }, "outputs": [], "source": [ "from fastai.utils.ipython import * " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Workarounds to the leaky ipython traceback on exception\n", "\n", "ipython has a feature where it stores tb with all the `locals()` tied in, which\n", "prevents `gc.collect()` from freeing those variables and leading to a leakage.\n", "\n", "Therefore we cleanse the tb before handing it over to ipython. The 2 ways of doing it are by either using the [`gpu_mem_restore`](/utils.ipython.html#gpu_mem_restore) decorator or the [`gpu_mem_restore_ctx`](/utils.ipython.html#gpu_mem_restore_ctx) context manager which are described next:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "
gpu_mem_restore
[source][test]gpu_mem_restore
(**`func`**)\n",
"\n",
"No tests found for gpu_mem_restore
. To contribute a test please refer to this guide and this discussion.
class
gpu_mem_restore_ctx
[source][test]gpu_mem_restore_ctx
()\n",
"\n",
"No tests found for gpu_mem_restore_ctx
. To contribute a test please refer to this guide and this discussion.