pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
27.84k stars 1.71k forks source link

permit run polars on old CPU #15404

Open l1t1 opened 3 months ago

l1t1 commented 3 months ago

Description

I have an old PC, it reported following errors. I hope polars can run on it.

C:\Users\lt>python
Python 3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import polars as pl
D:\Python312\Lib\site-packages\polars\_cpu_check.py:232: RuntimeWarning: Missing required CPU features.

The following required CPU features were not detected:
    sse4.2, popcnt, avx, avx2, fma, bmi1, bmi2, lzcnt, pclmulqdq
Continuing to use this version of Polars on this processor will likely result in a crash.
Install the `polars-lts-cpu` package instead of `polars` to run Polars with better compatibility.

Hint: If you are on an Apple ARM machine (e.g. M1) this is likely due to running Python under Rosetta.
It is recommended to install a native version of Python that does not run under Rosetta x86-64 emulation.

If you believe this warning to be a false positive, you can set the `POLARS_SKIP_CPU_CHECK` environment variable to bypass this check.

  warnings.warn(

C:\Users\lt>set POLARS_SKIP_CPU_CHECK=1

C:\Users\lt>python
Python 3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import polars as pl #exited python again
l1t1 commented 3 months ago

I installed polars-lts-cpu package, but don't know how to import it. import polars-lts-cpu says invalid syntax

l1t1 commented 3 months ago

I uninstalled both polars and polars-lts-cpu, then installed polars-lts-cpu again, when import polars, it shows following error. it says there are still two features needed by it. sse4.2, popcnt. But in fact they also can be ignored. could it skip the checks by default?

>>> import polars as pl
D:\Python312\Lib\site-packages\polars\_cpu_check.py:232: RuntimeWarning: Missing required CPU features.

The following required CPU features were not detected:
    sse4.2, popcnt
Continuing to use this version of Polars on this processor will likely result in a crash.
Install the `polars-lts-cpu` package instead of `polars` to run Polars with better compatibility.

Hint: If you are on an Apple ARM machine (e.g. M1) this is likely due to running Python under Rosetta.
It is recommended to install a native version of Python that does not run under Rosetta x86-64 emulation.

If you believe this warning to be a false positive, you can set the `POLARS_SKIP_CPU_CHECK` environment variable to bypass this check.

  warnings.warn(

works

C:\Users\lt>set POLARS_SKIP_CPU_CHECK=1

C:\Users\lt>python
Python 3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import polars
>>> import polars as pl
>>> df = pl.DataFrame(
... {
...     "A": [1, 2, 3, 4, 5],
...     "fruits": ["banana", "banana", "apple", "apple", "banana"],
...     "B": [5, 4, 3, 2, 1],
...     "cars": ["beetle", "audi", "beetle", "beetle", "beetle"],
... }
... )
>>> df.sort("fruits")
shape: (5, 4)
┌─────┬────────┬─────┬────────┐
│ A   ┆ fruits ┆ B   ┆ cars   │
│ --- ┆ ---    ┆ --- ┆ ---    │
│ i64 ┆ str    ┆ i64 ┆ str    │
╞═════╪════════╪═════╪════════╡
│ 3   ┆ apple  ┆ 3   ┆ beetle │
│ 4   ┆ apple  ┆ 2   ┆ beetle │
│ 1   ┆ banana ┆ 5   ┆ beetle │
│ 2   ┆ banana ┆ 4   ┆ audi   │
│ 5   ┆ banana ┆ 1   ┆ beetle │
└─────┴────────┴─────┴────────┘
l1t1 commented 3 months ago

I uninstalled both polars and polars-lts-cpu, then installed polars-lts-cpu again, when import polars, it shows following error. it says there are still two features needed by it. sse4.2, popcnt. But in fact they also can be ignored. could it skip the checks by default?

>>> import polars as pl
D:\Python312\Lib\site-packages\polars\_cpu_check.py:232: RuntimeWarning: Missing required CPU features.

The following required CPU features were not detected:
    sse4.2, popcnt
Continuing to use this version of Polars on this processor will likely result in a crash.
Install the `polars-lts-cpu` package instead of `polars` to run Polars with better compatibility.

Hint: If you are on an Apple ARM machine (e.g. M1) this is likely due to running Python under Rosetta.
It is recommended to install a native version of Python that does not run under Rosetta x86-64 emulation.

If you believe this warning to be a false positive, you can set the `POLARS_SKIP_CPU_CHECK` environment variable to bypass this check.

  warnings.warn(

works

C:\Users\lt>set POLARS_SKIP_CPU_CHECK=1

C:\Users\lt>python
Python 3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import polars
>>> import polars as pl
>>> df = pl.DataFrame(
... {
...     "A": [1, 2, 3, 4, 5],
...     "fruits": ["banana", "banana", "apple", "apple", "banana"],
...     "B": [5, 4, 3, 2, 1],
...     "cars": ["beetle", "audi", "beetle", "beetle", "beetle"],
... }
... )
>>> df.sort("fruits")
shape: (5, 4)
┌─────┬────────┬─────┬────────┐
│ A   ┆ fruits ┆ B   ┆ cars   │
│ --- ┆ ---    ┆ --- ┆ ---    │
│ i64 ┆ str    ┆ i64 ┆ str    │
╞═════╪════════╪═════╪════════╡
│ 3   ┆ apple  ┆ 3   ┆ beetle │
│ 4   ┆ apple  ┆ 2   ┆ beetle │
│ 1   ┆ banana ┆ 5   ┆ beetle │
│ 2   ┆ banana ┆ 4   ┆ audi   │
│ 5   ┆ banana ┆ 1   ┆ beetle │
└─────┴────────┴─────┴────────┘
l1t1 commented 3 months ago

failed to run df.sort("fruits").select(

>>> import polars as pl
>>> df = pl.DataFrame(
...  {
...     "A": [1, 2, 3, 4, 5],
...     "fruits": ["banana", "banana", "apple", "apple", "banana"],
...     "B": [5, 4, 3, 2, 1],
...     "cars": ["beetle", "audi", "beetle", "beetle", "beetle"],
...  }
... )
>>> df.sort("fruits").select(
...  "fruits",
...  "cars",
...  pl.lit("fruits").alias("literal_string_fruits"),
...  pl.col("B").filter(pl.col("cars") == "beetle").sum(),
...  pl.col("A").filter(pl.col("B") > 2).sum().over("cars").alias("sum_A_by_cars"),
...  pl.col("A").sum().over("fruits").alias("sum_A_by_fruits"),
...  pl.col("A").reverse().over("fruits").alias("rev_A_by_fruits"),
...  pl.col("A").sort_by("B").over("fruits").alias("sort_A_by_B_by_fruits"),
... )
ritchie46 commented 3 months ago

What is your machine?

l1t1 commented 3 months ago

my machine: intel core2 duo p8700

ritchie46 commented 3 months ago

I think we can remove those features from polars-lts-cpu.

ritchie46 commented 3 months ago

failed to run df.sort("fruits").select(

What doe you mean by failed? What happened?

I am a bit hesitant on understanding how old you machine is. As a popcnt is for instance required to boot the windows 11 kernel.

l1t1 commented 3 months ago

failed to run df.sort("fruits").select( means python exit without output anything. I installed windows 10.

l1t1 commented 2 months ago

the latest clickhouse supports my old cpu. https://builds.clickhouse.com/master/amd64compat/clickhouse