小编BoK*_*enU的帖子

docker上的cuda版本和PC上的cuda版本不同有关系吗?

我的电脑上安装了 cuda-10.1。目前cuda的最新版本是cuda11.0。我正在考虑使用 docker cuda 版本 11.0,而不更改我的 PC 上的 cuda 版本。那么这样的话容器中使用的cuda会是11.0吗?

cuda docker nvidia-docker

11
推荐指数
1
解决办法
8187
查看次数

我想使用 Rust 中的 match 语句的条件来执行“0..=a+5”

我想使用 Rust 的match语句在变量处于任意范围和其他情况下以不同的方式处理变量。在这种情况下,代码将如下所示:

// idx is usize variable
// num is usize variabel

let res: Option<f64> = match idx {
    1..=num-5 => {
        Some(func())
    },
    _ => None,
};
Run Code Online (Sandbox Code Playgroud)

但我收到一个错误:

error: expected one of `::`, `=>`, `if`, or `|`, found `-`
  --> src/features.rs:34:22
   |
34 |         1..=num-5 => Some(func()),
   |            ^ expected one of `::`, `=>`, `if`, or `|`
Run Code Online (Sandbox Code Playgroud)

rust

9
推荐指数
1
解决办法
7719
查看次数

如何停止lightgbm的日志输出?

我想知道如何停止 lightgbm 日志记录。我应该使用什么样的设置来停止日志?另外,有没有办法在 lightgbm 日志停止的情况下只输出自己的日志?

python logging python-3.x lightgbm

8
推荐指数
1
解决办法
2万
查看次数

如何使用 Rocket_contrib Json?

我是 Rust 和 Rocket 的初学者。我试图通过阅读官方存储库中的示例来理解 Rocket。所以有个例子叫content_type,里面有诸如此类的描述// NOTE: In a real application, we'd use `rocket_contrib::json::Json`.

所以我尝试使用带有 Rocket_contrib 的 Json。该示例的代码如下所示。

#[macro_use] extern crate rocket;

#[cfg(test)] mod tests;

use std::io;

use rocket::request::Request;
use rocket::data::{Data, ToByteUnit};
use rocket::response::{Debug, content::{Json, Html}};

use serde::{Serialize, Deserialize};

#[derive(Debug, Serialize, Deserialize)]
struct Person {
    name: String,
    age: u8,
}

#[get("/<name>/<age>", format = "json")]
fn get_hello(name: String, age: u8) -> Json<String> {
    // NOTE: In a real application, we'd use `rocket_contrib::json::Json`.
    let person = Person { name, age …
Run Code Online (Sandbox Code Playgroud)

rust rust-rocket

4
推荐指数
1
解决办法
1249
查看次数

如何删除值周围的“MutexGuard”?

我正在尝试使用 ndarray 作为异步过程来进行线性代数等。我使用 Rust 的 tokio 和 ndarray 创建了以下代码。

use std::sync::{Arc, Mutex};
use ndarray::prelude::*;
use futures::future::join_all;

fn print_type_of<T>(_: &T) {
    println!("{}", std::any::type_name::<T>())
}


#[tokio::main]
async fn main() {
    let db = Arc::new(Mutex::new(array![0,0,0,0,0,0,0,0]));
    let mut handels = vec![];

    for i in 0..8 {
        let db = db.clone();
        let unchange_array = unchange_array.clone();
        handels.push(tokio::spawn(async move{
            print(i, db).await;
        }));
    }
    join_all(handels).await;
    let array = Arc::try_unwrap(db).unwrap();
    let array = array.lock().unwrap();
    print_type_of(&array);  // -> std::sync::mutex::MutexGuard<ndarray::ArrayBase<ndarray::data_repr::OwnedRepr<u32>, ndarray::dimension::dim::Dim<[usize; 1]>>>

}

async fn print(i: u32, db: Arc<Mutex<Array1<u32>>>) {
    let …
Run Code Online (Sandbox Code Playgroud)

rust

4
推荐指数
1
解决办法
5461
查看次数

如何在Flutter中使用GoRouter隐藏特定路由中的BottomNavigationBar?

https://github.com/flutter/packages/blob/main/packages/go_router/example/lib/others/custom_stateful_shell_route.dart 在此代码中,即使显示详细信息,ButtomBar 也始终显示。但是,我想在查看“a/details”时隐藏ButtomBar。有没有办法做到这一点?

一种可能的方法是使用navigationShell.shellRouteContext.routerState.matchedLocation.contains('details'). 但我认为应该有一个更简单的方法。这应该怎么做呢?

具体来说,我想根据下一节中当前显示的页面来确定是否启用或禁用按钮栏。

class ScaffoldWithNavBar extends StatelessWidget {
  const ScaffoldWithNavBar({
    required this.navigationShell,
    required this.children,
    Key? key,
  }) : super(key: key ?? const ValueKey<String>('ScaffoldWithNavBar'));

  final StatefulNavigationShell navigationShell;

  /// ([AnimatedBranchContainer]).
  final List<Widget> children;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: AnimatedBranchContainer(
        currentIndex: navigationShell.currentIndex,
        children: children,
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Section A'),
          BottomNavigationBarItem(icon: Icon(Icons.work), label: 'Section B'),
        ],
        currentIndex: navigationShell.currentIndex,
        onTap: (int index) => _onTap(context, index),
      ),
    );
  }
Run Code Online (Sandbox Code Playgroud)

flutter flutter-go-router

4
推荐指数
1
解决办法
1458
查看次数