AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-1635450

khteh's questions

Martin Hope
khteh
Asked: 2025-04-04 11:19:47 +0800 CST

运行 Ollama 作为 k8s STS,使用外部脚本作为入口点来加载模型

  • 5

我设法将 Ollama 作为 k8s STS 运行。我将其用于 Python Langchain LLM/RAG 应用程序。但是,以下 DockerfileENTRYPOINT脚本尝试MODELS从 k8s STS 清单中提取作为 ENV 导出的图像列表时遇到问题。Dockerfile 具有以下ENTRYPOINT内容CMD:

ENTRYPOINT ["/usr/local/bin/run.sh"]
CMD ["bash"]

run.sh:

#!/bin/bash
set -x
ollama serve&
sleep 10
models="${MODELS//,/ }"
for i in "${models[@]}"; do \
      echo model: $i  \
      ollama pull $i \
    done

k8s日志:

+ models=llama3.2
/usr/local/bin/run.sh: line 10: syntax error: unexpected end of file

David Maze 的解决方案:

          lifecycle:
            postStart:
              exec:
                command:
                  - bash
                  - -c
                  - |
                    for i in $(seq 10); do
                      ollama ps && break
                      sleep 1
                    done
                    for model in ${MODELS//,/ }; do
                      ollama pull "$model"
                    done
ollama-0          1/2     CrashLoopBackOff     4 (3s ago)        115s
ollama-1          1/2     CrashLoopBackOff     4 (1s ago)        115s
  Warning  FailedPostStartHook  106s (x3 over 2m14s)  kubelet            PostStartHook failed
$ k logs -fp ollama-0
Defaulted container "ollama" out of: ollama, fluentd
Error: unknown command "ollama" for "ollama"

更新Dockerfile:

ENTRYPOINT ["/bin/ollama"]
#CMD ["bash"]
CMD ["ollama", "serve"]

我需要定制Dockerfile以便可以安装 Nvidia Container Toolkit。

kubernetes
  • 1 个回答
  • 27 Views
Martin Hope
khteh
Asked: 2025-04-03 20:24:32 +0800 CST

Dockerfile 和容器从 k8s Statefulset 获取 ENV

  • 4

我需要在容器启动之前处理来自 k8s Statefulset 的 ENV Dockerfile。:

RUN echo CREDENTIALS: $CREDENTIALS
ARG user="${CREDENTIALS%/*}"
ARG password="${CREDENTIALS#*/}"
ENV USER $user
ENV PASSWORD $password

Statefulset环境:

          env:
            - name: CREDENTIALS
              valueFrom:
                secretKeyRef:
                  name: app-secret
                  key: CREDENTIALS

当我使用 运行时d run -dt -e CREDENTIALS="user/P@$$w0rd" myimage:latest,PASSWORD丢失了。

kubernetes
  • 1 个回答
  • 32 Views
Martin Hope
khteh
Asked: 2025-02-19 17:32:13 +0800 CST

Pandas 按多列分组,聚合某些列,添加每组的计数列[重复]

  • 7
这个问题已经有答案了:
Pandas groupBy 多列和聚合 (1 个答案)
20 小时前关闭。

我正在处理的数据:

data (140631115432592), ndim: 2, size: 3947910, shape: (232230, 17)
VIN (1-10)                                            object
County                                                object
City                                                  object
State                                                 object
Postal Code                                          float64
Model Year                                             int64
Make                                                  object
Model                                                 object
Electric Vehicle Type                                 object
Clean Alternative Fuel Vehicle (CAFV) Eligibility     object
Electric Range                                       float64
Base MSRP                                            float64
Legislative District                                 float64
DOL Vehicle ID                                         int64
Vehicle Location                                      object
Electric Utility                                      object
2020 Census Tract                                    float64
dtype: object
   VIN (1-10)    County      City State  Postal Code  ...  Legislative District DOL Vehicle ID             Vehicle Location                               Electric Utility 2020 Census Tract
0  2T3YL4DV0E      King  Bellevue    WA      98005.0  ...                  41.0      186450183   POINT (-122.1621 47.64441)  PUGET SOUND ENERGY INC||CITY OF TACOMA - (WA)      5.303302e+10
1  5YJ3E1EB6K      King   Bothell    WA      98011.0  ...                   1.0      478093654  POINT (-122.20563 47.76144)  PUGET SOUND ENERGY INC||CITY OF TACOMA - (WA)      5.303302e+10
2  5UX43EU02S  Thurston   Olympia    WA      98502.0  ...                  35.0      274800718  POINT (-122.92333 47.03779)                         PUGET SOUND ENERGY INC      5.306701e+10
3  JTMAB3FV5R  Thurston   Olympia    WA      98513.0  ...                   2.0      260758165  POINT (-122.81754 46.98876)                         PUGET SOUND ENERGY INC      5.306701e+10
4  5YJYGDEE8M    Yakima     Selah    WA      98942.0  ...                  15.0      236581355  POINT (-120.53145 46.65405)                                     PACIFICORP      5.307700e+10

csv 格式的数据:

VIN (1-10),County,City,State,Postal Code,Model Year,Make,Model,Electric Vehicle Type,Clean Alternative Fuel Vehicle (CAFV) Eligibility,Electric Range,Base MSRP,Legislative District,DOL Vehicle ID,Vehicle Location,Electric Utility,2020 Census Tract
2T3YL4DV0E,King,Bellevue,WA,98005,2014,TOYOTA,RAV4,Battery Electric Vehicle (BEV),Clean Alternative Fuel Vehicle Eligible,103,0,41,186450183,POINT (-122.1621 47.64441),PUGET SOUND ENERGY INC||CITY OF TACOMA - (WA),53033023604
5YJ3E1EB6K,King,Bothell,WA,98011,2019,TESLA,MODEL 3,Battery Electric Vehicle (BEV),Clean Alternative Fuel Vehicle Eligible,220,0,1,478093654,POINT (-122.20563 47.76144),PUGET SOUND ENERGY INC||CITY OF TACOMA - (WA),53033022102
5UX43EU02S,Thurston,Olympia,WA,98502,2025,BMW,X5,Plug-in Hybrid Electric Vehicle (PHEV),Clean Alternative Fuel Vehicle Eligible,40,0,35,274800718,POINT (-122.92333 47.03779),PUGET SOUND ENERGY INC,53067011902
JTMAB3FV5R,Thurston,Olympia,WA,98513,2024,TOYOTA,RAV4 PRIME,Plug-in Hybrid Electric Vehicle (PHEV),Clean Alternative Fuel Vehicle Eligible,42,0,2,260758165,POINT (-122.81754 46.98876),PUGET SOUND ENERGY INC,53067012332
5YJYGDEE8M,Yakima,Selah,WA,98942,2021,TESLA,MODEL Y,Battery Electric Vehicle (BEV),Eligibility unknown as battery range has not been researched,0,0,15,236581355,POINT (-120.53145 46.65405),PACIFICORP,53077003200
3C3CFFGE1G,Thurston,Olympia,WA,98501,2016,FIAT,500,Battery Electric Vehicle (BEV),Clean Alternative Fuel Vehicle Eligible,84,0,22,294762219,POINT (-122.89166 47.03956),PUGET SOUND ENERGY INC,53067010802
5YJ3E1EA4J,Snohomish,Marysville,WA,98271,2018,TESLA,MODEL 3,Battery Electric Vehicle (BEV),Clean Alternative Fuel Vehicle Eligible,215,0,39,270125096,POINT (-122.1677 48.11026),PUGET SOUND ENERGY INC,53061052808
5YJ3E1EA3K,King,Seattle,WA,98102,2019,TESLA,MODEL 3,Battery Electric Vehicle (BEV),Clean Alternative Fuel Vehicle Eligible,220,0,43,238776492,POINT (-122.32427 47.63433),CITY OF SEATTLE - (WA)|CITY OF TACOMA - (WA),53033006600
1N4AZ0CP5E,Thurston,Yelm,WA,98597,2014,NISSAN,LEAF,Battery Electric Vehicle (BEV),Clean Alternative Fuel Vehicle Eligible,84,0,2,257246118,POINT (-122.60735 46.94239),PUGET SOUND ENERGY INC,53067012421

过滤和分组:

filt = (data["Model Year"] >= 2018) & (data["Electric Vehicle Type"] == "Battery Electric Vehicle (BEV)")
data = data[filt].groupby(["State", "Make"], sort=False, observed=True, as_index=False).agg( avg_electric_range=pd.NamedAgg(column="Electric Range", aggfunc="mean"), oldest_model_year=pd.NamedAgg(column="Model Year", aggfunc="min"))

目前它产生下表:

  State       Make  avg_electric_range  oldest_model_year
0    WA      TESLA           52.143448               2018
1    WA     NISSAN           60.051874               2018
<snip>

如何添加一Count列来显示每个组的数量,以便进一步过滤?注意:排除apply所有东西,因为一切都应该留在 Pandas'land 中。

python
  • 2 个回答
  • 40 Views
Martin Hope
khteh
Asked: 2025-02-19 13:13:20 +0800 CST

VSCode C++ CMake 无法构建 Release 版本

  • 6

我运行CMake: Select Variant选择Relaese并CMake: Configure更新buid/CMakeCache.txt以反映变体:

CMAKE_BUILD_TYPE:STRING=Release

CMake 扩展是 VSCode在项目状态Release中显示的Configure。但是,构建总是在x64/Debug文件夹中输出构建工件,并且二进制文件是用而不是构建的,CMAKE_CXX_FLAGS_DEBUG正如CMAKE_CXX_FLAGS_RELEASE我使用file命令检查时显示的那样with debug_info, not stripped

我Release在 VSCode 终端输出中看到:

build task started....
/usr/bin/cmake --build /usr/src/MyApp/build --config Release --target all --

然而,在构建结束时,可执行文件被链接并构建在Debug文件夹中:

[6/6 100% :: 11.014] Linking CXX executable /usr/src/MyApp/x64/Debug/Console

CMake: Log Diagnostics:

{
  "os": "linux",
  "vscodeVersion": "1.94.2",
  "cmtVersion": "1.19.52",
  "configurations": [
    {
      "folder": "/usr/src/MyApp",
      "cmakeVersion": "3.30.3",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {
        "C": "/usr/bin/gcc",
        "CXX": "/usr/bin/g++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Release",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 31,
    "executablesCount": 2,
    "librariesCount": 1,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]

当我CMake: Configure从 VSCode 命令面板运行时:

[cpptools] The build configurations generated do not contain the active build configuration. Using "Debug" for CMAKE_BUILD_TYPE instead of "Release" to ensure that IntelliSense configurations can be found
visual-studio-code
  • 1 个回答
  • 32 Views
Martin Hope
khteh
Asked: 2025-02-13 14:32:27 +0800 CST

如何匹配“C”、“C++”或“C#”?[重复]

  • 4
此问题这里已有答案:
正则表达式匹配两个单词中的一个 (2 个答案)
34 分钟前关闭。

我有以下测试用例:

CPP_CSHARP_REGEX_TEST_CASES = [
    ("C++", True),
    ("C#", True),
    ("C+", False),
    ("C##", False),
    ("C", True),
]

我可以使用哪个正则表达式来通过 pytest?我尝试过r"^C[+{2},#{1}]$" Tim Biegeleisen 的解决方案,但失败了C:

________________________________________________________________________________ test_cpp_csharpRegex[C-True] ________________________________________________________________________________

data = 'C', expected = True

    @pytest.mark.parametrize("data, expected", CPP_CSHARP_REGEX_TEST_CASES)
    def test_cpp_csharpRegex(data, expected):
        cpp_csharp_regex = r"\bC(?:\+\+|#)(?=\s|$)"
>       assert expected == bool(re.match(cpp_csharp_regex, data))
E       AssertionError: assert True == False
E        +  where False = bool(None)
E        +    where None = <function match at 0x7ab4e2cded40>('\\bC(?:\\+\\+|#)(?=\\s|$)', 'C')
E        +      where <function match at 0x7ab4e2cded40> = re.match

regex_test.py:131: AssertionError
================================================================================== short test summary info ===================================================================================
FAILED regex_test.py::test_cpp_csharpRegex[C-True] - AssertionError: assert True == False
================================================================================ 1 failed, 70 passed in 0.08s ================================================================================
regex
  • 1 个回答
  • 61 Views
Martin Hope
khteh
Asked: 2025-02-07 21:34:01 +0800 CST

c++ long double(128位精度)

  • 6

我尝试使用以下代码片段在 64 位系统上计算阶乘:

long double FactorialLD(long n)
{
    long double result = 1;
    if (n <= 0)
        return 1;
    for (long i = 2; i <= n; i++)
        result *= i;
    return result;
}

30!返回265252859812191058647452510846976。但是,使用桌面计算器或https://www.calculatorsoup.com/calculators/discretemathematics/factorials.php返回265252859812191058636308480000000。为什么会有这么大的差异,是什么原因造成的?

CPU:英特尔x86_64

操作系统:Ubuntu 24.10

编译器:g++ 14.2.0

x86-64
  • 1 个回答
  • 61 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve