For those who run their own AI box, or want to

That’s odd - do you know what caused that?

No, I can only speculate.
Sorry I didn’t pay exact attention to original nameserver IP. It was was something like 172.x.x.x. I see right now the WSL-IP is 172.31.200.178. My WIN11-IP is 10.1.1.116 using the home wireless router as its DNS=10.1.1.1. So it seems WSL is NATd and expects WIN11 to forward its DNS requests to dns-cache-forwarder on the wireless router. That might be blocked by a Windows Firewall rule, or such Win11 service might not exist.

I haven’t played much with the Hyper-V Virtual Switch, but I guess “Internal” means NAT. Perhaps if WSL was conenct externally direct to the wireless network it would get its DNS configured by DHCP response from the wireless router - but I’m not bothering to test that for now. 8.8.8.8 is such an easy number to remember and hasn’t changed in 20 years, so its simpler for me to update resolv.conf than chase other issues.

There is a long discussion here.
Note this is WSL2 on Win11. Apparently WSL1 is okay.

I’ve never seen the problem on WSL2 - I see from the github discussion that quite a few people have seen it, but I’ve set up maybe a dozen WSL installs in a range of environments and never came across that issue.

Just mentioning that so people coming across this thread in the future know they shouldn’t change their DNS settings, unless they happen to hit the same issue you did.

1 Like

btw, do you know the proportion of Win10 or Win11 on those dozen machines. There may be differences. I’m on Win11, but only since a couple of weeks. Also can you share if your WSL connection type is “Internal” (NAT) or “External” (bridged)?
Here says

With the introduction of WSL 2 Beta, Microsoft has made changes to the system architecture.
The changes include changing from the default bridged network adapter to a hyper-v virtual network adapter.

No need to reply to the rest of this. Just sharing a few things I gathered up from poking around.
Some are a bit of a stretch.

Far down page here says…

disabling TCP/Offload Engine on all network cards fix the issue

This will be interesting for me to look into… ( I don’t have a .wslconfig file yet )

just add .wslconfig in c:\users\yourusername\.wslconfig
with the following:
[wsl2]
localhostForwarding=true

To flesh out my understanding of the environment…

For WSL2 the DNS resolver runs on the host

This one is interesting, I’ll keep my eye on…

I noticed that my $ ip addr didn’t quite match my \>ipconfig

might be related to…

Having a new IP address assigned to WSL2 every time it is launched creates additional work when DNS and virtual environments are used to access web applications for testing and development.

And I haven’t fully digested the following yet, but looks like a good reference…
Understanding how DNS works in Hyper-V

Not looking for a response. Just sharing tonights experience since having to document it slows me down so I gain a better understanding, and maybe its useful for someone else…

Opened WSL shell.

$ ping google.com
ping:  google.com: Temporary failure in name resolution

$ cat /etc/resolv.conf
cat: /etc/resolv.conf: No such file or directory

Wow! thats a suprise, that the system removed that file.
Restarted Windows LxssManager service to reboot Linux Subsystem.
Opened new WSL shell
resolv.conf still missing. Ahh… maybe need…

/etc/wsl.conf
[network]
- generateResolvConf = false
+ generateResolvConf = true

Rebooted Linux Subsystem again and opened new shell, and it had created the file

$ cat /etc/resolv.conf
nameserver 172.31.192.1

$ ifconfig
eth0: inet 172.31.201.159  netmask 255.255.240.0  broadcast 172.31.207.255

# linux host IP and nameserver IP are on the same subnet (172.31.192.1 - 172.31.207.254)
# so expected to be on same layer 2 virtual switch, no routing.

$ ping 172.31.192.1  #nameserver
33 packets transmitted, 0 received, 100% packet loss, time 33284ms

$ ping 10.1.1.116    #Win-host
10 packets transmitted, 0 received, 100% packet loss, time 9393ms

$ ping 10.1.1.1     #Wireless gateway
64 bytes from 10.1.1.1: icmp_seq=1 ttl=63 time=6.39 ms

From Windows side vEthernet(WSL) IP matches linux host. good.

C:> ipconfig /all
Wireless LAN adapter Wi-Fi:
   Description . . . . . . . . . . . : Qualcomm QCA61x4A 802.11ac Wireless Adapter
   DHCP Enabled. . . . . . . . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 10.1.1.116(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 10.1.1.1
   DHCP Server . . . . . . . . . . . : 10.1.1.1
   DNS Servers . . . . . . . . . . . : 10.1.1.1
Ethernet adapter vEthernet (Default Switch):
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter
   IPv4 Address. . . . . . . . . . . : 172.29.64.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
Ethernet adapter vEthernet (WSL):
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #2
   IPv4 Address. . . . . . . . . . . : 172.31.192.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.240.0

$ ping 172.31.201.159  #WSL eth0
Reply from 172.31.201.159: bytes=32 time<1ms TTL=64

$ ping 172.31.192.1   #WSL nameserver
Reply from 172.31.192.1: bytes=32 time<1ms TTL=128

So Win11-host can nameserver, but WSL can’t.
Win11-host can ping WSL, but WSL can’t ping Win11-host.
WSL can ping wireless-router.
Firewall had been turned off during this.

Looking in the registery, it seems that 172.31.192.1 (the expected namserver)
is associated with an interface that no longer shows up for ipconfig. Maybe it was picked up when WSL was installed.

Now I just realised something about, my machine that might be different to others with working DNS. I already had a Windows 10 Virtual Machine configured before I installed WSL. And actually that was created after I had deleted a previous one. Anyway…

1 Like

[Solved] retaining WSL DNS configuration

So this will be my final post on this.

To avoid the annoyance of /etc/resolve.conf being overwritten with a bad configuration every restart of LxssManager, I’m doing what several forums suggested, and making the file immutable. First need to unlink it from /mnt/wsl/resolv.conf since can’t make that immutable. I using google servers, rather than a local gateway since that would change between home and work.

$ sudo chattr +i /mnt/wsl/resolv.conf
chattr: Inappropriate ioctl for device while reading flags on /mnt/wsl/resolv.conf

$ sudo rm /etc/resolv.conf
$ sudo sh -c 'echo nameserver 8.8.8.8 > /etc/resolv.conf'
$ sudo chattr +i /etc/resolv.conf

Now after restarting LxssManager…

$ cat /etc/resolv.conf
nameserver 8.8.8.8

$ PING google.com (142.250.70.238) 56(84) bytes of data.
64 bytes from mel05s02-in-f14.1e100.net (142.250.70.238): icmp_seq=1 ttl=56 time=61.1 ms

That is sufficient for now.

Not sure if I imagined it, but I think the initial install of an Ubuntu distro had a checkbox for auto generating the resolv.conf. I’m wondering if some paths in the installation are somehow skipping this. I haven’t seen the problem myself, and like Jeremy have loaded various distros across several different machines. As an aside I was pleasantly surprised to see the latest Ubuntu managed to use my NVIDIA Quadro M2000M in my old ZBook G3 GPU. Only 4GB Memory, and slow (2:30 per epoch on cats v dogs) but it worked.

2 Likes

No checkboxes when I install like… wsl --install -d Ubuntu

No, this was through the Microsoft Store install process I recall. If I can get on a clean box I’ll try and find it again. I just added 20.04 to my existing 22.04 and didn’t see the option.

When first starting my local Jupyter install, it was disconcerting that all extensions were disabled OOTB due to compatability.

I see in Lesson 2 video [8:55] Jeremy has cleared that flag, so I presume its generally safe to do so…

But I’m curious about a bit more context on the state of play of nbextensions stability.
A bit of hunting did turn up a comment (2021-09-01) that…

until now nbextensions compatibility test is only for Jupyter Notebook 4.x and 5.x, about 6.x Compatibility testing has not been implemented yet. If this option is selected, under the version 6.x , all functions will be disabled.

And the issue seems to be outstanding for 2.5 years without much stress on this thread…

So what are your experiences?

Cheers, ben

p.s. here are my Jupyter versions. Would I be correct to say I’m on Jupyter 7.3.1?

$ jupyter --version
IPython          : 8.3.0
ipykernel        : 6.13.0
ipywidgets       : not installed
jupyter_client   : 7.3.1
jupyter_core     : 4.9.2
jupyter_server   : not installed
jupyterlab       : not installed
nbclient         : 0.6.2
nbconvert        : 6.5.0
nbformat         : 5.4.0
notebook         : 6.4.11
qtconsole        : not installed
traitlets        : 5.1.1

p.s.2. Which python should I use for new notebooks?..
image

I wanted to test the doc() function in my new install.
Having done $ mamba install -c fastai nbdev
I thought I would only neeed to do…

I have reviewed nbdev tutorial | nbdev, but nothing stood out.

I can do doc(function_name) and get results without having to install / import nbdev (maybe in my case it is come through fastbook/fastai imports? not sure. It works OOTB for me (fastai 2.6.3)

That’s true - it does work without nbdev. It just doesn’t look quite as cool :slight_smile:

1 Like

You need to import it. from fastai.vision.all import * for instance would grab it.

That might make a good FAQ. From the videos the strongest association I got for doc() was with nbdev. So now on Colab I got doc() working for the first time, with:

#once !pip install -U fastai nbdev
import fastai, nbdev
from fastai.vision.all import *
doc(print)
fastai.__version__ , nbdev.__version__ 
____________________
print[source]
print()
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default. Optional keyword arguments: file: a file-like object (stream); defaults to the current sys.stdout. sep: string inserted between values, default a space. end: string appended after the last value, default a newline. flush: whether to forcibly flush the stream.
('2.6.3', '1.2.8')

But that same code doesn’t work on my local install. Below I’ve included my environment check and startup procedure.

$ mamba install -c fastai nbdev
Looking for: ['nbdev']
conda-forge/linux-64                                        Using cache
conda-forge/noarch                                          Using cache
fastai/noarch                                                 No change
fastai/linux-64                                               No change
Pinned packages:
  - python 3.9.*
Transaction
  Prefix: /home/ben/mambaforge
  All requested packages already installed

$ jupyter notebook
[I 08:01:53.138 NotebookApp] [nb_conda_kernels] enabled, 1 kernels found
[I 08:01:53.286 NotebookApp] [jupyter_nbextensions_configurator] enabled 0.4.1
[I 08:01:53.287 NotebookApp] Serving notebooks from local directory: /home/ben/jupyter
[I 08:01:53.288 NotebookApp] Jupyter Notebook 6.4.11 is running at:
[I 08:01:53.288 NotebookApp] http://localhost:8888/?token=924b4706d9f1d5689b053235903c80f1dc47833e55da1a9e
[I 08:01:53.288 NotebookApp]  or http://127.0.0.1:8888/?token=924b4706d9f1d5689b053235903c80f1dc47833e55da1a9e
[I 08:01:53.288 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

AFAIK, the conda install reports that fastai is installed correct.
[Edit:] Whoops, thats wrong! I had misunderstood the “-c” flag, which actually
means “install ‘nbdev’ from the ‘fastiai’ channel” and not “install ‘fastai’ itself”.

But in the notebook it complains… No module named 'fastai’

[Edit:] Fixed by doing…

$ mamba install -c fastchan fastai

where fastchan is described here.

Thanks @balnazzar and @Interogativ. I tried your ideas, but they did not solve the multiple problems. After a lot of frustration, I ended up starting fresh - completely uninstalling/reinstalling anaconda. Then installing fastai and nbdev into the base environment, following Jeremy’s suggestion. It all seems to be working now, for the new course at least, and a good house cleaning.

Whew!

I am guessing that conda was somehow corrupted, but who can tell at this point. I may need to reinstall a few more packages for existing side projects, and those ought to be obvious. :woozy_face:

2 Likes

After learning a bit about conda channels, what is the preference between fastai and fastchan channels ? Comparing the two I see some overlap, some differences…

$ conda search --override-channels -c fastai \
      | cut -d\  -f1 | sort -u > /tmp/fastai
$ conda search --override-channels -c fastchan \
      | cut -d\  -f1 | sort -u > /tmp/fastchan
$ diff -y /tmp/fastchan /tmp/fastai
#                          #
Loading                    Loading
abseil-cpp               <
accelerate                 accelerate
albumentations             albumentations
arrow-cpp                <
aws-c-cal                <
aws-c-event-stream       <
aws-c-io                 <
aws-checksums            <
aws-sdk-cpp              <
boa                      <
catalogue                <
cudatoolkit              <
cython-blis              <
datasets                 <
fastai                     fastai
                         > fastai2
                         > fastbook
fastcgi                    fastcgi
fastcore                   fastcore
                         > fastdoc
                         > fastdot
fastdownload               fastdownload
                         > fastgpu
fastprogress               fastprogress
fastrelease                fastrelease
ffmpeg                   | fastscript
                         > gh
ghapi                      ghapi
glog                     | imgaug
grpc-cpp                 | jlang
huggingface_hub          <
inotify_simple           <
keyutils                 <
krb5                     <
langcodes                <
lerc                     <
libarchive               <
libblas                  <
libbrotlicommon          <
libbrotlidec             <
libbrotlienc             <
libcblas                 <
libclang                 <
libcrc32c                <
libcurl                  <
libcxx                   <
libdeflate               <
libevent                 <
libgcc-ng                <
libgfortran-ng           <
libgfortran5             <
libgomp                  <
libgoogle-cloud          <
libiconv                 <
liblapack                <
libmamba                 <
libmambapy               <
libnghttp2               <
libpq                    <
libprotobuf              <
libsolv                  <
libssh2                  <
libstdcxx-ng             <
libthrift                <
libtiff                  <
libutf8proc              <
libxml2                  <
libzlib                  <
llvm-openmp              <
mamba                    <
mysql-common             <
mysql-libs               <
nbdev                      nbdev
numexpr                  | nbdev-django
numpy                    | nbdev-numpy
                         > nbdev-pandas
                         > nbdev-pytorch
                         > nbdev-scipy
                         > nbdev-sphinx
                         > nbdev-stdlib
                         > nvidia-ml-py3
opencv-python-headless     opencv-python-headless
orc                      <
pillow                   <
protobuf                 <
pyarrow                  <
pybind11-abi             <
pynvml                     pynvml
pyqt                     <
pyqt-impl                <
pyqt5-sip                <
pyqtchart                <
pyqtwebengine            <
python_abi               <
pytorch                  <
pytorch-cpu              <
qt                       <
re2                      <
reproc                   <
reproc-cpp               <
rich                     <
s2n                      <
sacremoses               <
scipy                    <
sentencepiece              sentencepiece
spacy                    | setuptools-conda
spacy-legacy             | showdoc
spacy-loggers            <
sqlite                   <
thinc                    <
timm                       timm
tokenizers               | tinykernel
torchaudio               <
torchvision              <
transformers             <
typer                    <
watchgod                 <
yaml-cpp                 <
zlib                     <
zstd                     <

fastai is where I publish fast.ai-developed libs. fastchan contains those libs, plus lots of libs useful to the fast.ai community that other folks have written, but aren’t available in the default anaconda channels.

2 Likes

This is the repo responsible for creating the fastchan channel FYI:

3 Likes

Well !! I was minding my own business when I bumped into the scent of another lead, so fell down this rabbit hole again to follow it. Other commitments mean I’ve run out of time this session, so summarizing interesting bits in case it helps others…

The behaviour I observed of /etc/resolv.conf being overwritten assumes a DNS Resolver will be listening on Localhost Port 53. That would forward requests to real DNS server at the ISP. A reasonable candidate to fulfil this Internet Connection Services configured by Host Networking Services, from what I see in my firewall rules…

Background: