# ERROR: Unable to load the kernel module 'nvidia.ko' [SOLVED]

## __Jackal__

I'm gettin the following error:

```
ERROR: Unable to load the kernel module 'nvidia.ko'.  This happens most

       frequently when this kernel module was built against the wrong or

       improperly configured kernel sources, with a version of gcc that differs

       from the one used to build the target kernel, or if a driver such as

       rivafb/nvidiafb is present and prevents the NVIDIA kernel module from

       obtaining ownership of the NVIDIA graphics device(s).

       

       Please see the log entries 'Kernel module load error' and 'Kernel

       messages' at the end of the file '/var/log/nvidia-installer.log' for

       more information.

-> Kernel module load error: insmod: error inserting './usr/src/nv/nvidia.ko':

```

I don't have rivafb/nvidiafb enabled.  I also believe the kernel was compiled with the same GCC version  because I just built his machine yesterday using a stage3 tarball, and gcc 4.1.1 is installed now.  I used the gentoo howto to get this far in installing the nvidia driver.  I also get the same results with the new driver install  from nvidia.

----------

## Headrush

What is the output of

```
ls -l /usr/src

uname -a
```

----------

## __Jackal__

```
ls -l /usr/src

total 1

lrwxrwxrwx  1 root root   22 Nov 13 14:28 linux -> linux-2.6.18-gentoo-r2

drwxr-xr-x 20 root root 1328 Nov 13 20:56 linux-2.6.18-gentoo-r2
```

```
uname-a

Linux gentoo 2.6.18-gentoo-r2 #7 Mon Nov 13 19:20:32 CST 2006 i686 Intel(R) Pentium(R) 4 CPU 2.80GHz GenuineIntel GNU/Linux

```

----------

## Headrush

What is the output of

```
ls -l /lib/modules/`uname -r`/video/
```

You didn't try installing the nvidia driver outside of portage did you? 

I don't know why it is looking for the module in ./usr/src/nv/nvidia.ko

----------

## __Jackal__

```
ls -l /lib/modules/`uname -r`/video/

total 5053

-rw-r--r-- 1 root root 5165175 Nov 13 14:29 nvidia.ko
```

Well, at first, I did use portage, and I got the same error.  Then i attemped to download the driver from Nvidia and use their installer, and got the same error.

----------

## Headrush

What is the output of

```
cat /lib/modules/`uname -r`/modules.dep | grep nvidia
```

----------

## __Jackal__

```
cat /lib/modules/`uname -r`/modules.dep | grep nvidia

/lib/modules/2.6.18-gentoo-r2/video/nvidia.ko: /lib/modules/2.6.18-gentoo-r2/kernel/drivers/char/agp/agpgart.ko
```

----------

## __Jackal__

Ok, could this be my problem?  I found to check this from another post.

```
filename:       /lib/modules/2.6.18-gentoo-r2/video/nvidia.ko

license:        NVIDIA

alias:          char-major-195-*

vermagic:       2.6.18-gentoo-r2 mod_unload PENTIUM4 REGPARM gcc-4.1

depends:        agpgart

alias:          pci:v000010DEd*sv*sd*bc03sc00i00*

alias:          pci:v000010DEd*sv*sd*bc03sc02i00*

parm:           NVreg_PanelBrightnessLimits:int

parm:           NVreg_PanelPWMFrequency:int

parm:           NVreg_EnableBrightnessControl:int

parm:           NVreg_SaveVBios:int

parm:           NVreg_VbiosFromROM:int

parm:           NVreg_DetectPrimaryVga:int

parm:           NVreg_UseCPA:int

parm:           NVreg_RemapLimit:int

parm:           NVreg_RmLogonRC:int

parm:           NVreg_VideoEnhancement:int

parm:           NVreg_DevicesConnected:int

parm:           NVreg_FlatPanelMode:int

parm:           NVreg_ResmanDebugLevel:int

parm:           NVreg_DeviceFileMode:int

parm:           NVreg_DeviceFileGID:int

parm:           NVreg_DeviceFileUID:int

parm:           NVreg_ModifyDeviceFiles:int

parm:           NVreg_Mobile:int

parm:           NVreg_SoftEDIDs:int

parm:           NVreg_EnableAGPFW:int

parm:           NVreg_EnableAGPSBA:int

parm:           NVreg_NvAGP:int

parm:           NVreg_ReqAGPRate:int

parm:           NVreg_EnableALiAGP:int

parm:           NVreg_EnableVia4x:int

parm:           NVreg_VideoMemoryTypeOverride:int

parm:           nv_disable_pat:int

```

```
Linux version 2.6.18-gentoo-r2 (root@gentoo) (gcc version 4.1.1 (Gentoo 4.1.1)) #7 Mon Nov 13 19:20:32 CST 2006
```

Are the the GCC versions different, one is 4.1, and the other 4.1.1?

----------

## __Jackal__

I'm attempting an emerge -eav system  and emerge -eav world, then i am going to recompile kernel.  I read this in another post.  This should make sure everything is compiled with GCC 4.1.1 which I emerged again beforehand.

----------

## wynn

 *__Jackal__ wrote:*   

> Ok, could this be my problem?
> 
> ```
> 
> vermagic:       2.6.18-gentoo-r2 mod_unload PENTIUM4 REGPARM gcc-4.1
> ...

 Not when comparing vermagic strings.

The kernel vermagic string (which is copied by modules when they are compiled, in-kernel or out-kernel) is defined as (include/linux/vermagic.h)

```
#define VERMAGIC_STRING                                                 \

        UTS_RELEASE " "                                                 \

        MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT                     \

        MODULE_VERMAGIC_MODULE_UNLOAD MODULE_ARCH_VERMAGIC              \

        "gcc-" __stringify(__GNUC__) "." __stringify(__GNUC_MINOR__)
```

so only the gcc version (first number) and the version minor number are used.

However, to match this string, the kernel must be built without SMP support, without PREEMPT support

```
Symbol: PREEMPT [=y]

 Prompt: Preemptible Kernel (Low-Latency Desktop)

   Defined at kernel/Kconfig.preempt:36

   Depends on: <choice>

   Location:

     -> Processor type and features

       -> Preemption Model (<choice> [=y]
```

with module unloading support

```
Symbol: MODULE_UNLOAD [=y]

 Prompt: Module unloading

   Defined at init/Kconfig:453

   Depends on: MODULES

   Location:

     -> Loadable module support

       -> Enable loadable module support (MODULES [=y])
```

the processor must be Pentium4 and

```
Symbol: REGPARM [=y]

 Prompt: Use register arguments

   Defined at arch/i386/Kconfig:709

   Location:

     -> Processor type and features
```

must also be supported.

----------

## __Jackal__

Thanks for the response.  This is what is set in my .config

```
CONFIG_MODULE_UNLOAD=y

CONFIG_PREEMPT_NONE=y

CONFIG_MPENTIUM4=y

# CONFIG_SMP is not set
```

----------

## __Jackal__

After doing an emerge -eav system and emerge -eav world and recompiling my kernel, I was able to load the module.

----------

